0

I want to add a field to a content type where the editor can select a class name from a drop down or simply enter a class name into a text field. I want this class name to then be added to the menu item's li tag.

The purpose is so that the editor can select an icon (based on Font awesome) when they are authoring a page of content.

The class should be added on the content authoring page, and not via a secondary step by editing the menu item itself from the menu manager. Note, I'm also using taxonomy menu to build the links.

Any suggestions would be appreciated.

0

How comfortable are you with code?

This sounds like a job for hook_preprecess() inside template.php to get the value of drop down field and store it to something like $var['my_class_to_insert']=. Then inside of whatever.tpl.php used for this situation, have <div class='$my_class_to_insert'>Content goes here</div>. See https://stackoverflow.com/questions/8124089/ for how to get the value of a field in the template.php file.

The drawbacks to this second approach is that you are coupling functionality to the theme layer and adding to "Drupal's Div Soup."

Or I'd look at two other modules before you open up a code editor. You could try to use logic in the Context Module

Context allows you to manage contextual conditions and reactions for different portions of your site. You can think of each context as representing a "section" of your site. For each context, you can choose the conditions that trigger this context to be active and choose different aspects of Drupal that should react to this active context.

And Rules may help out...

The Rules module allows site administrators to define conditionally executed actions based on occurring events (known as reactive or ECA rules). It's a replacement with more features for the trigger module in core and the successor of the Drupal 5 workflow-ng module.

Rules and Context also have a world of other modules that add additional pieces of functionality.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.