What is the shortest and best way to do this |
[eluser]miauksius[/eluser]
Hi, I'm creating a blog. Now, my layout is divided to four parts: header.php main_content.php - blog articles are shown here, ant this is area where main content is shown sidebar.php - some boxes with info, links footer.php So, my main page shows blog articles. I fetch all them in my controller and model, also I have a box in sidebar, where I display latest 5 blog articles. So I catch five blog articles for main_content.php and catch five titles for sidebar.php. I have a page called 'About', well, method, and when I display some content there, I still use sidebar (it will always be shown), and every single time, when I include sidebar.php I have to pass to it array with those 5 articles titles. How can I avoid doing that?
[eluser]PhilTem[/eluser]
Either you create a MY_Controller which handles this stuff. Maybe you have to use method _output, but I'm not very familiar with that one. The easiest thing I'd suggest is to use a template library like the one from @philsturgen and put the sidebar inside your wrapper-template (which contains header, sidebar and footer) and only create the main-content per controller/method. The content for your sidebar will then be created/set (refer to the wiki for the template-lib) by your MY_Controller and: Tada, the magic begins ;D |
Welcome Guest, Not a member yet? Register Sign In |