Navigation with links from db. How? |
[eluser]halex[/eluser]
I want to make navigation with link from a table, say 'links'. A bad solution: Any controller: Code: ... In ...partial/header: Code: <div id="container"> This way I make database access for each page which use left_nav, although changes in 'links' table seldom happens. Another solution is to search in sources as wordpress or joomla, but... I'm lazy ;-) Are anybody a better solution for that? Thanks. (As you can see, I'm not an English speaker/writer, sorry)
[eluser]halex[/eluser]
I've searched again and it seems that isn't another solution. I'm a disappointed n00b!
[eluser]nmweb[/eluser]
You can use a file cache or any other cache (memory) to store the links. This way you don't have to query the db on every request. I also recommend putting this code in a Wiredesignz hmvc module.
[eluser]halex[/eluser]
Thanks, nmweb! I haven't used caching yet, is a good tip. Thanks again.
[eluser]deck1[/eluser]
You can use something like this: In your controller: Code: $this->load->library('layout'); application/libraries/Layout.php: Code: <?php
[eluser]Chris Newton[/eluser]
That assumes you're already using the layout library, which isn't part of the default install: http://codeigniter.com/wiki/layout_library/ You could also write out the navigation to a view file when the links table is updated. Long-term caching. Basically you pull the navigation from a file, rather than the database. If you're making changes to the 'links' table through an admin interface, that admin application could also write out a new view_navigation.php file at the same time the database is being updated. |
Welcome Guest, Not a member yet? Register Sign In |