Introducing the Menu Attributes module
Over the Christmas break I decided that I’d had enough of hard coding theme functions to add attributes to specific menu items in Drupal, so I finally took the time to write a module that would do the heavy lifting. The outcome is the Menu Attributes module.
All the module does is give you the ability to add attributes to the menu item <a> elements, but this has been something I've wanted in Drupal for a long time now.
The main reason I wrote the module was to add the rel="nofollow" attribute to certain menu items (learn why you should be using nofollow to direct PageRank to high value pages), but it made sense to allow users to set other valid attributes as well. So far I have included the Id, Name, Target, Rel, Class, Style, and Accesskey attributes which can be added to any menu item. If you think other attributes would be useful, let me know I’m happy to consider including them.
In the next couple of weeks or so I’ll be releasing an update to include an admin page so that you can choose which attributes are available on the menu form so as not to overcrowd the form with items that you’ll never use.
It’s worth noting that the actual attributes are stored in the menu_links table in the options field of the menu item itself so no new databases are needed and no additional processing done when building the menu. The one drawback of this is that there is no way to mass reset the attributes you’ve set using the module, because it is stored alongside other attributes that are set by other modules.
If you’ve got any other uses or feedback for the module, I’d love to hear them in the comments.
Comments
Thanks for a great module! I
Thanks for a great module!
I would love to see automatic creation of id's and classnames. Perhapse using patterns like pathauto:
menu-[title-raw]
Thnx for the treat! But yeah
Thnx for the treat! But yeah Thnkx for spending the time to discuss this, I feel strongly about it and love reading more on this topic. great blog and post, i feel great reading about this topic.
nice post
I desired to thank you for this exceptional read!! I absolutely enjoyed every single small little bit of it. I’ve you bookmarked your internet site to look at out the new stuff you post.2m hdmi cable
was getting an error notice:
was getting an error
notice: Undefined index: id in /var/www/.../modules/menu_attributes/menu_attributes.module on line 68.
change line 64 to
if (variable_get('menu_attributes_id_enable', 1) && isset($item['options']['attributes']['id'])) {
and it fixed it.
Just letting you know.
thanks
I wanted to write a quick note to express my thanks. I'm really impressed by a blog unique and perfectly chosen and organized!Acai Berry Diet
would it be better to target the <li> for id and class
Wouldn't it be better to target the menu item li instead of the ?
Or wouldn't it be better to have fields for such?
All styling and jquery related tasks that target the <a> are still feasible, but now you can affect the parent <li> as easily.
Also I think that using Schoonie's idea is feasible for using menu related tokens.
J
fix that: target the list items, instead of the anchors?
sorry about badly formatting my last post, it's obviously too late for me to be writing this to you.
I meant to ask:
Wouldn't it be better to target the menu item < li > tags instead of the < a > tags. This would make targeting the parent list items feasible, without affecting your ability to target the anchors?
Then I actually checked your module and realized that the code that you're plugging into doesn't get to affect the list-item; it uses the existing theming functionality of the menu system, which only themes each anchor and then drops it into a list item.
Sorry about that.
Menu image backgrounds with rollovers and actives question
I wonder if someone could suggest a good way to overload menu items with images.
First I'm using this fantastic module to set a unique id for the menu item (e.g. #menu-item)
I'm using some css along the lines of:
#menu-item {
font-size: 0px; /* hide the link text */
display: block; /* force the size of the anchor */
width: 200px;
height: 25px;
background-image: url('image.jpg'); /* place the image */
}
#menu-item:hover {
background-image: url('hover.jpg');
}
#menu-item:active {
background-image: url('active.jpg');
}
In particular I'm focusing on how to hide the old link text, but keep the text, and have it make the entire background image an active target for a click.
I'd like to do this using just css of course, and not have to resort to using jquery to remove the old text.
The problem is that the fashion of hiding the text isn't working on all version of webkit. Is this font-size=0 what other people are doing?
J
THANK YOU
Holy crap, thank you so much. I've been working on creating a theme from scratch for the first time, and I needed to use images in my primary links. This helps immensely!
Attaching menu attributes is
Attaching menu attributes is beneficial for viewers to use the module efficiently.I am not sure whether the whole procedure is instant or not so I request to attach its enhancement too.
I am glad to have landed in
I am glad to have landed in the post for its useful lesson on introduction of the menu attributes module in drupal. I think I've been benefited by the essential tutorial. thanks.
It is quite beneficial to
It is quite beneficial to learn about the module which does give you the ability to add attributes to the menu item. I am glad to learn more about the module and its functioning.
Extremely an knowledgeable
Extremely an knowledgeable package about the uses of all attributes module items.Elaborating this procedure about addition of module individually is really an helpful concept for drupal application.
It is an excellent
It is an excellent information to learn about this simple module which allows us to specify some additional attributes for menu items; id, name, class, style, etc. Thanks.
The webforms such as
The webforms such as questionnaires, contact or request/register forms, surveys etc. are some of the features provided by drupal modules. thanks.
Hi there, Really nice
Hi there,
Really nice job,There are many people searching about that now they will find enough sources by your tips.
Also looking forward for more tips about that
Regards,
www.genericsmed.com
Introducing the menu
Introducing the menu attributes module is a very important part of implementation in Drupal case.I am impressed as they are providing a better opportunity to the menu attributes by installing some relevant features in it.
Testking 220-702
You have done really nice job. There are many people searching about that now they will find enough sources by your tips.
Module is to give you the
Module is to give you the ability to add attributes to the menu item in drupal. I've found the discussion exactly as per my requirement. As usual, it's a useful information.
Please keep us informed like
Please keep us informed like this. Thanks for sharing. I’m glad that you shared this helpful info with us.
Nice
I always interested in such a innovative material.
Nice One
Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. If possible, as you gain expertise, would you mind updating your blog with more information? It is extremely helpful for me.
thank you for writing, I
thank you for writing, I truly liked your most recent story. I think it is best to post far more typically, you clearly have all-natural capacity for blogging!Zakłady sportowe
It is really beneficial to
It is really beneficial to introduce the menu attributes module in drupal. It ensures faster and wider delivery. It is also encouraging to note a number of attributes such id, name, target etc. in the menu item. Yours is a nice job.
Integrate with menu_block
I'm not using the drupal main/secondary core menu functions, rather I'm using menu_blocks to inserting menus into my page (via the genesis theme) and it appears that there's no integration for menu_attributes on menu_blocks. That would be an awesome feature.
The main reason I appreciate
The main reason I appreciate this module is that is allow users to set other valid attributes as well according to their requirement.
If you are accustomed to
If you are accustomed to using the default style set in word 2007, we would be able not only to save time and energy but also create an effective project.
Family quotes
Such as this web-site your web site is 1 of my new most popular.I similar to this information shown and it has offered me some sort of ideas to possess success for some cause, so keep up the excellent work!
arthritis advice
The post is actually the freshest on this laudable subject. I harmonize with your conclusions and will thirstily look forward to see your approaching updates.
arthritis advice
Quality Audit Bangladesh
Your post is excellent. I learn much from your article. Life is a beautiful journey. Everyone can only live but once. Wise people knows that we should enjoy our life. We should care about everything around us. Clothes, foods, friends, families and everything. Come on, make a better world for you and for me.
Took me time to read all the
Took me time to read all the comments, but I really enjoyed the article. It proved to be Very helpful to me and I am sure to all the commenter here! It’s always nice when you can not only be informed, but also entertained!
I have been examination out
I have been examination out some of your stories and i can state pretty nice stuff. I will surely bookmark your blog
great post
I have to see anyone, you happen to be absolutely in.
Jilbab online My spouse and i came up Only two this information via some other blog site along with are intensely captivated by this specific subject matter along with understading about Kaos Futsal this specific. Does one head only examine this specific information via our facebook or myspace web site?
in regard
sad hindi sms
I think you made some really interesting points. Not too many people would have to think about how you just made. I'm really impressed that there is so much information on this subject has been revealed, and you did so well with so much class. Thank you.
Its not saying completely
Its not saying completely wrong that Module attributes are my favorite available in Drupal, these attribute clarifies many adding features to it in a very simple manner which definitely helps us to have a hard coding theme functions.
In the next couples of weeks
In the next couples of weeks or so I’ll be releasing an update to include an admin page so that you can choose which attributes are available on the menu paradigm so as not to overcrowd the pattern with item that you’ll never use.
Monster beats pro black headphone
This is a really good post.Monster beats studio diamond white headphone
Monster beats studio white headphone
Must admit that you are amongst the best bloggers I have read. Thanks for posting this informative article.
This is what I have been
This is what I have been searching in many websites and I finally found it here. Amazing article. I am so impressed with 24option review site. Could never think of such a thing is possible with it...I think you have a great knowledge especially while dealings with such subjects
Amazing article
hi this post is pretty appreciated! I just bookkmarked this site.
Houston Alarm Monitoring
I want to show my admiration of your writing skill and ability to make audience, browse the whole thing to the end. I'd really like to read more of your blogs and to talk about my views with you. I'll be your frequent website visitor, that’s for sure.
Through this comprehensive
Through this comprehensive discussion regarding Menu Attributes module,Users could be able to use the modules frequently by gaining vast knowledge from this in Drupal.Above concept provides sufficient knowledge to specify some additional attributes for menu items.Impressive post i must say.
Not too many people would
Not too many people would have to think about how you just made. I'm really impressed that there is so much information on this subject has been revealed, and you did so well with so much class. Thank you.
Basically a menu attributes
Basically a menu attributes module allows us to specify some additional items in the menu, so while over look this post I was just realizing the whole concepts of Menu Attributes module.
Drupal is one of the most
Drupal is one of the most prominent CMS language which helps to developing content management system in a website and here we got some better note for arranging a perfect menu attribute module.




