Dynamic Navigation

edited August 2011 in Modules
I am trying to create a navigation that automatically adds new items created by a custom (simple) module.
So far I have this;
$nav = array();
$nav['news'] = array('label' => 'News', 'active' => 'news$|news/:any');
$nav['contact'] = 'Contact';
$nav['tracks'] = array('label' => 'Tracks', 'active' => 'tracks$|tracks/:any');

$CI =& get_instance();
$tracks = $CI->tracks_model->fetch_nav_list();
foreach($tracks as $track)
$nav['tracks/'.$track['slug']] = array('label' => $track['name'], 'parent_id' => 'tracks');

Which when I upload works a treat, but if I create a new 'track' (using the simple module) is isn't getting added to the navigation. Any thoughts, is it a cache issue or does fuel_nav not get run on every page load?

Any help is appreciated.


  • edited 2:19AM
    So when you say "when I upload" do you mean you actually upload the PHP file in the Navigation module? If so, then the navigation won't pull in those tracks. If you are just using the nav.php file and not controlling the navigation in the admin, then it should work the way you have it and if you aren't seeing it, it could very well be a cache issue and in that case you can click the Clear Cache menu item on the left in the admin to resolve.

    If you are wanting to control the navigation in the admin and would like that every time you insert a new track, it also creates a menu item, you would need to use a model hook on your tracks_model (e.g. on_after_save()) to create/edit that navigation record. You could also use that hook to clear the cache.
Sign In or Register to comment.