Andreyco
Andreyco

Reputation: 22862

Good logic of View helper for CodeIgniter


Could someone tell what is good logic for creating custom helper for Views?

What I would like to accomplish is...

Could someone point me to the solution?

Thanks a lot, in advance!

Upvotes: 2

Views: 1805

Answers (5)

Phil Sturgeon
Phil Sturgeon

Reputation: 30766

For a Template library that is more actively developed than Collin's (linked by predrag.music) try out mine:

https://github.com/philsturgeon/codeigniter-template

His is good but this supports modules, themes, mobile version variations of themes and plenty more.

Upvotes: 1

dqhendricks
dqhendricks

Reputation: 19251

Some people will create a master template, then pass the sub content's view name in the data object. The master template will call the header view, footer view, etc, and use the data array to dynamically display the correct sub content view.

Upvotes: 2

kevtrout
kevtrout

Reputation: 4984

This question gives some explanation to the method dqhendricks describes. It includes code examples showing how to use $this->load->view() to return the view to a variable instead of outputting it to the browser, how to include sub-views, and using a specific view as your main template. It's the best way I've found of handling view logic. Getting the hang of CodeIgniter - Templating / loading views

Upvotes: 2

Diablo
Diablo

Reputation: 3418

If you need something for the reference this one is good:

http://williamsconcepts.com/ci/codeigniter/libraries/template/reference.html

Upvotes: 1

DampeS8N
DampeS8N

Reputation: 3621

you could use inheritance chaining (with a custom controller class or with an included extra class that extends controller that you extend from your controllers instead of the controller class) to make a common controller hub for all pages that has a method for the top stuff, and a method for the bottom stuff.

Upvotes: 1

Related Questions