Hello,
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();
$CI->load->model('tracks_model');
$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.
Comments
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.