Smarty like templates? |
[eluser]feri_soft[/eluser]
How can i include one view in another much like smarty i dont want the smarty like syntax but the normal CI php based templates. I just need to have one view inside another so that i dont need to change all view for a menu item for example. Thanks!
[eluser]kucerar[/eluser]
Maybe you want sort of flexible view code inside a static template. Here's what I do: /app/templates/mytheme/main.html: Code: <html> At the top and bottom of my code view: Code: <?php That's it. This maybe simple but unlike Smarty internals you can read it, and already you've got sort of theme support. -R
[eluser]sophistry[/eluser]
@kucerar... this solution is similar to the ruby on rails 'yield' functionality which someone has implemented in a standard CI way using a CI hook. using hooks, you avoid putting a bunch of functional PHP in a view file. check out the link in the FAQ to find the thread or just search on yield in the CI forums here. cheers.
[eluser]kucerar[/eluser]
Thanks sofistry. I like CI hooks. Not sure if the "yield" concept is a bit confusing though. Is a string replacement? -R
[eluser]sophistry[/eluser]
agreed yield can be confusing to grasp at first - it is basically string replacement like you outlined above, but the PHP internals are not embedded in the view file. you can put PHP in a view, but the typical way of deciding how to structure code in there is to imagine a 'designer' working with your view files. now, you may or may not be working with designers but in any case it is a good way to help decide where to put functional code versus display code. cheers.
[eluser]kucerar[/eluser]
Agreed, thanks again...think I'll be going with Layout Library though http://codeigniter.com/wiki/layout_library/ less mystery... -R
[eluser]sophistry[/eluser]
yep. the layout library at the wiki is another variation on the string replacement idea to get a nested view. That's listed in the FAQ too, please add other solutions to the FAQ if you find something good. I've tried to collect all of them because each developer approaches the problem in a different way. Personally, I prefer coolfactor's view library.
[eluser]feri_soft[/eluser]
Thanks all i found very helpful thing in your posts. |
Welcome Guest, Not a member yet? Register Sign In |