GetSimple Support Forum
Add to menu - Printable Version

+- GetSimple Support Forum (http://get-simple.info/forums)
+-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3)
+--- Forum: Feature Requests (http://get-simple.info/forums/forumdisplay.php?fid=7)
+--- Thread: Add to menu (/showthread.php?tid=858)



Add to menu - jamiewhiskers - 2010-07-19

Hey,

An add to menu hook would be very helpful, as theres a lot of code wasted in my current way to of doing thing.

having a blank page called "store" then having everything run under a content-top hook and a function that checks to make sure everthing is only displayed on the "store" page.

Im sorry if that makes little sense, I just woke up and have yet to have my coffee.


Add to menu - JWH_Matthew - 2010-07-19

Would you like the hook above the first or after the last li?

I think after the last li would be nice.


Add to menu - jamiewhiskers - 2010-07-19

I would like to able to choose in the hook itself, so that its location can be suited to each plugin/menu by the user. But if i had no choice then the after the last li would be best i belive.


Add to menu - Zegnåt - 2010-07-20

Choosing a location to have the hook the way the menu function is currently working will be a bit hard. It will be easy to add some hooks before and after the generated LI-elements. I haven’t committed this to the latest dev version (yet) but here’s what you could do:

Open up /admin/inc/theme_functions.php and scroll all the way down (row 362). Here you will find this:
Code:
echo $menu;
Now change it to this:
Code:
exec_action('pre-menuitems');
echo $menu;
exec_action('post-menuitems');
Now use these two hooks (pre-menuitems, post-menuitems) as normal.

I’ll be looking into this a bit for the next GetSimple version. It would be nice to have a little more control over the menu as plugin developers.


Add to menu - Carlos - 2010-07-20

Maybe just the pre-menuitems hook is needed for this -- instead of echoing the additional "<li>..." code, it could be appended to the $menu variable (to the beginning or end of the string, depending on where you want it to be displayed).

Another idea... What about using a filter, instead of hooks?
Line 362 of theme_functions.php could then be changed to:
Code:
echo exec_filter('menuitems',$menu);



Add to menu - ccagle8 - 2010-09-22

Carlos Wrote:cho exec_filter('menuitems',$menu);
I like your idea... i've just added it to the core. Thanks Carlos!