Advertisement:

Author Topic: Displaying selected buttons outside template_menu()  (Read 921 times)

Offline phantomm

  • Sr. Member
  • ****
  • Posts: 883
  • Gender: Male
    • pages/smfpl/171860759503032 on Facebook
Displaying selected buttons outside template_menu()
« on: May 30, 2012, 04:27:29 PM »
Hi, I saw this in few themes, but couldn't find out how this is done.

How to display buttons Register and Login in index.template.php but hide them in template_menu() ? Don't remember where I've seen it, but I hope you understand what I mean :)
Polskie wsparcie SMF na simplemachines.org

My mods

Offline Suki

  • SMF Super Hero
  • *******
  • Posts: 11,254
  • Kaizoku Jotei
    • Free SMF mods
Re: Displaying selected buttons outside template_menu()
« Reply #1 on: May 30, 2012, 04:30:29 PM »
If you are using 2.0 you can just remove those buttons from the array or set the 'show' =>  to false:  'show' => false,  the just add your buttons manually  to your template where you want them, the url is pretty simple in both cases:  ?action=login and ?action=register
The devil will find work for idle hands to do.

Offline phantomm

  • Sr. Member
  • ****
  • Posts: 883
  • Gender: Male
    • pages/smfpl/171860759503032 on Facebook
Re: Displaying selected buttons outside template_menu()
« Reply #2 on: May 30, 2012, 04:36:27 PM »
Yes, I'm using 2.0.2, I want to limit all edits in theme, because if I hide buttons in Subs.php then they will be hidden in other themes
Polskie wsparcie SMF na simplemachines.org

My mods

Offline Suki

  • SMF Super Hero
  • *******
  • Posts: 11,254
  • Kaizoku Jotei
    • Free SMF mods
Re: Displaying selected buttons outside template_menu()
« Reply #3 on: May 30, 2012, 04:38:47 PM »
So, you want to only hide some buttons on specific themes?

You could do a ternary on 'show' =>  to check what is the theme the user is using and if is equal to X then disable the button with false.
The devil will find work for idle hands to do.

Offline Arantor

  • SMF Legend
  • *
  • Posts: 50,928
    • wedgebook on Facebook
Re: Displaying selected buttons outside template_menu()
« Reply #4 on: May 30, 2012, 04:40:53 PM »
You could modify your theme's template_menu() to just not show the buttons in that theme... in the loop, check for the button's id and if it's login or register, just don't show it.

This is what some of DzinerStudio's premium themes do.


All we're really talking about is finding this line in template_menu:
Code: [Select]
foreach ($context['menu_buttons'] as $act => $button)
And adding after it:
Code: [Select]
if ($act == 'login' || $act == 'register')
  continue;

Offline phantomm

  • Sr. Member
  • ****
  • Posts: 883
  • Gender: Male
    • pages/smfpl/171860759503032 on Facebook
Re: Displaying selected buttons outside template_menu()
« Reply #5 on: May 30, 2012, 05:09:18 PM »
and this is it :) Thanks Arantor :)
Polskie wsparcie SMF na simplemachines.org

My mods