Quick question about editing the Menu

Started by d3vcho, August 15, 2016, 10:38:09 AM

Previous topic - Next topic

d3vcho

Hi!

I want to create a clickable dropdown menu for those tabs with subelements. The thing is that I couldn't find where to edit those tabs of the menu.. For example for those tabs with subelements I want to place an arrow next to them. I've been looking for a while around Subs and Subs-Menu but I couldn't find it...

I'm using 2.0.11 and the default theme.

Thank you :)
"Greeting Death as an old friend, they departed this life as equals"

All Colours Sam

It depends on what do you want to do. Is this for a theme or a mod?  What menu do you want to modify, the main menu (the one with home, search, calendar, etc)  the admin menu, the profile menu?
Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

d3vcho

It's for a theme. And I want to edit the Main Menu.
"Greeting Death as an old friend, they departed this life as equals"

All Colours Sam

Then it will be on your theme's index.template.php

function template_menu()  takes a $context array and applies HTML to it to form a menu, usually a combination of uls and lis.

You can use $button['sub_buttons'] to know if a parent button has sub-elements, using a ternary would do the trick:


<a class="', $button['active_button'] ? 'active ' : '', 'firstlevel" href="', $button['href'], '"', isset($button['target']) ? ' target="' . $button['target'] . '"' : '', '>
<span class="', isset($button['is_last']) ? 'last ' : '', 'firstlevel">', $button['title'], '</span>
</a>';



<a class="', $button['active_button'] ? 'active ' : '', 'firstlevel" href="', $button['href'], '"', isset($button['target']) ? ' target="' . $button['target'] . '"' : '', '', !empty($button['sub_buttons']) ? 'aqui tu flecha' : '' ,'>
<span class="', isset($button['is_last']) ? 'last ' : '', 'firstlevel">', $button['title'], '</span>
</a>';
Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

d3vcho

I applied the changes but nothing seems to be changed... I'm a PHP newbie, so sorry about that.

What should I put exactly in "aquí tu flecha"? I put a simple "^" just to check, but it's not displayed.
"Greeting Death as an old friend, they departed this life as equals"

All Colours Sam

The ternary is inside the anchor tag, which means "aqui tu flecha" will appear inside the anchor tag before the closing >

It depends on what you want to do, if you want to add a new class or an ID to the anchor or the parent li or create a new tag inside the anchor tag or inside the parent li, just move around the ternary bit:

', !empty($button['sub_buttons']) ? 'aqui tu flecha' : '' ,'

To the place you want.
Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

d3vcho

"Greeting Death as an old friend, they departed this life as equals"

Advertisement: