add custom parameter in menu item

Need help with the Administration of your Joomla! 3.x site? This is the spot for you.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Post Reply
pepperoni
Joomla! Apprentice
Joomla! Apprentice
Posts: 13
Joined: Thu May 27, 2010 10:36 am

add custom parameter in menu item

Post by pepperoni » Mon Sep 16, 2019 5:28 pm

Hello,

I'd like to add an extra parameter for every menu item and use it in my template.
What I mean is if I go to Menus->Main Menu and select one of the menu items, ie home, I view the menu item and the first tab is Details.

In that tab I'd like to add a new parameter at the end, below "Template Style", ex. "Main Colour" with a dropdown that lists some colour options which I set manually.

I will then use that parameter selection accordingly in my template.

I'm not keen on using a component, only if I must. I don't mind writing some code myself, but I'd like it in a way that it won't break when I update Joomla.

Any tips and help much appreciated.

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 26127
Joined: Mon Oct 27, 2008 9:27 pm
Location: Akershus, Norway

Re: add custom parameter in menu item

Post by Per Yngve Berg » Mon Sep 16, 2019 7:33 pm

Define the colour in the template style and assign the template style to a menu item.

pepperoni
Joomla! Apprentice
Joomla! Apprentice
Posts: 13
Joined: Thu May 27, 2010 10:36 am

Re: add custom parameter in menu item

Post by pepperoni » Mon Sep 16, 2019 8:45 pm

Not sure if I understood this right, but every menu item might have different colour set. If I'm not mistaken setting the parameter in template style means I can only set one colour for all menu items?

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 26127
Joined: Mon Oct 27, 2008 9:27 pm
Location: Akershus, Norway

Re: add custom parameter in menu item

Post by Per Yngve Berg » Tue Sep 17, 2019 4:43 pm

Make a copy of the template style and change colour. Assign this copy to a menu item.

User avatar
imanickam
Joomla! Master
Joomla! Master
Posts: 27301
Joined: Wed Aug 13, 2008 2:57 am
Location: Chennai, India

Re: add custom parameter in menu item

Post by imanickam » Tue Sep 17, 2019 5:22 pm

If the requirement is that each menu item would have its own color, then you could use the option Link Class that is available in the tab Link Type when you edit a menu item. Once you define Link Class for each menu item, you could add the class definition css in your template's css file or if your template supports a custom/user css file then you could define those classes in that file.
Ilagnayeru (MIG) Manickam | இளஞாயிறு மாணிக்கம்
Joomla! - Global Moderators Team | Translations Coordination Team | Tamil (தமிழ்) Translation Team

Eegan - Support the poor and underprivileged

pepperoni
Joomla! Apprentice
Joomla! Apprentice
Posts: 13
Joined: Thu May 27, 2010 10:36 am

Re: add custom parameter in menu item

Post by pepperoni » Wed Sep 18, 2019 8:27 am

Per Yngve Berg wrote:
Tue Sep 17, 2019 4:43 pm
Make a copy of the template style and change colour. Assign this copy to a menu item.
Thanks Per Yngve Berg, I thought about that initially but thats is not very convenient in my case, as this procedure will create template folders with files for no real reason.

SharkyKZ
Joomla! Ace
Joomla! Ace
Posts: 1641
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: add custom parameter in menu item

Post by SharkyKZ » Wed Sep 18, 2019 8:58 am

You are confusing Templates with Template Styles. Template Styles have no files, they're stored in database only. They're essentially different configurations for a template. It's a good option if you want the same style applied to multiple menu items.

If you do want to add extra fields to menu items anyways, you'll have to make a plugin with onContentPrepareForm event https://docs.joomla.org/Adding_custom_f ... g_a_plugin.

pepperoni
Joomla! Apprentice
Joomla! Apprentice
Posts: 13
Joined: Thu May 27, 2010 10:36 am

Re: add custom parameter in menu item

Post by pepperoni » Wed Sep 18, 2019 10:42 am

SharkyKZ wrote:
Wed Sep 18, 2019 8:58 am
You are confusing Templates with Template Styles. Template Styles have no files, they're stored in database only. They're essentially different configurations for a template. It's a good option if you want the same style applied to multiple menu items.

If you do want to add extra fields to menu items anyways, you'll have to make a plugin with onContentPrepareForm event https://docs.joomla.org/Adding_custom_f ... g_a_plugin.
That is true! Sorry I was confused. That seems to be a good solution actually, I will start using this and see if it's working out good for me.

Thanks SharkyKZ and Per Yngve Berg


imanickam wrote:
Tue Sep 17, 2019 5:22 pm
If the requirement is that each menu item would have its own color, then you could use the option Link Class that is available in the tab Link Type when you edit a menu item. Once you define Link Class for each menu item, you could add the class definition css in your template's css file or if your template supports a custom/user css file then you could define those classes in that file.
Thanks imanickam, this is a solution of course which I have thought too as a back-up but not very user friendly for the non technical admin. No select/options will be shown.

cheers guys


Post Reply

Return to “Administration Joomla! 3.x”