Closed (outdated)
Project:
Drupal core
Version:
7.x-dev
Component:
toolbar.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
17 Aug 2009 at 08:55 UTC
Updated:
14 Jan 2015 at 05:52 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
TheRec commentedIn my code example, there is a mistake, the path of the second link is "/admin/content" too ;)
And the generated code once you applied the code should be :
mlid could vary depending on your installation, so the value of the CSS ID could not be exactly those for you, but they should be different between those two links.
Comment #2
mr.baileysUgh, invalid markup, yuck. Good catch, definitely needs fixing...
Quick review of the patch:
String concatenation operator should have spaces before and after (http://drupal.org/coding-standards#concat).
I'm wondering if this could create issues for themers. If the mlid is not guarantueed to be the same across sites, the id becomes unreliable to target specific menu items. As an alternative, the current id could become a class value instead, and the id could be shortened to something like
toolbar-item-<mlid>?Setting to CNW for #1, #2 is up for discussion...
Comment #3
TheRec commentedAbout 1., Ok, it will be corrected in the follow-up(s).
About 2. Themeing those with a CSS class does not make more sense (to me at least), for example the menu items that made this "bug" apparent are in two different menus (a submenu of Mangement and Administration Shortcuts), cases where this would be useful are rare in my opinion because you'll change both menu item apparence.
To theme them, you'd usually use their parent CSS class and the HTML element as selector (as it is done in toolbar.css) to theme all the menu items, and in last resort (if you need to theme a particular menu item) use the menu item ID. If you need something more, you can always override theme functions.
I like the idea of path-based CSS ID, it makes it easier to maintain your CSS (
toolbar-item-<mlid>would remove this concept), but they must be unique.I'd like to hear more ideas about how this CSS could be generated so that it would be really unique, one which would not turn into something too big (i.e. not keeping a registry of all the CSS ID already used or similar gas factories) for this small task. Using the text of the link or the menu title is not realistic either, because you could have two items with the same text and path. This left me with the solution of the mlid, until now I always used this trick when theming with Drupal 6, but it ties the theme to one install usually, which is not a valid solution for core, so we should maybe drop the idea of unique ID in core and leave that to themers (or modules like menu_attributes) ?
Comment #4
gábor hojtsymlid can totally depend on the order of menu items created, so it is not possible to give predictable icons to items with these IDs. There is
<ul id="toolbar-menu">and<ul id="toolbar-shortcuts">to match for the CSS, so we can just make this a class instead of an ID and allow for multiple items to have the same class. The CSS can assign icons to items under #toolbar-shortcuts, but not under #toolbar-menu.Comment #5
TheRec commentedOk so mlid are not acceptable. And we require a way to theme shortcut individually to be able to assign them icons, but we cannot give unique CSS ID's reliably, so this is why I repurpose this issue and leave it up for grabs.
We discussed on IRC about it with Gábor Hojtsy and we decided that we should drop the current ID on the
<a>and that themers could use the path based class of the<li>. For example to style the "Find content" shortcut, the CSS selector would be#toolbar-shortcuts li.path-admin-content. It removes the ID collisions and gives enough space to theme items individually. It should be noted that if there are two items with the same path in the same menu, the generated class will be the same for both, and it could cause problems for themers, in this edge case there is always the possibility for them to use theme override functions (menu) or contributed modules as mentioned before.On this clean base of thoughts, the way the
$link['href']is cleaned to make CSS id/class is not reliable when there menu items point to an URL with a querystring or for external URL... so we should put some work in this at the same time.Comment #6
TheRec commentedOk, this path does what I described in my previous message.
No more ID for the links, but they are themable individually with the class of their parent which is based on the path. The way used to clean the path has been changed and now should be exhaustive and always meet the CSS2 W3C recommandation for CSS identifiers. Tested it with :
admin/contentgeneratespath-admin-contentadmin/content?test1=val1&test2=val2generatespath-admin-content-test1-val1-test2-val2<front>special case :<front>generatespath-fronthttp://www.example.com/generatespath-http-www-example-comhttp://www.example.com/?test1=val1&test2=val2generatespath-http-www-example-com-test1-val1-test2-val2Comment #8
TheRec commentedRe-rolling... due to #326539: Convert 'class' attribute to use an array, not a string.
Comment #9
TheRec commentedMarked #557492: duplicate id: toolbar-link-admin-content as duplicate.
Comment #11
TheRec commentedPatch applies and tests pass locally.
Comment #12
yoroy commentedtag
Comment #13
cosmicdreams commentedused patch -p0 < 551172-toolbar-css-class_2.patch to apply the patch. The patch failed to apply to today's latest CVS.
here's the .rej file.
Comment #14
cosmicdreams commentedI'll give this another try soon.
Comment #15
cosmicdreams commented#8: 551172-toolbar-css-class_2.patch queued for re-testing.
Comment #17
cosmicdreams commentedah good, then it isn't just me.
Comment #18
eigentor commentedHere is the issue that plans to build on this patch: adding icons to "Add content" and "Find content" #735656: Iconize most important Items
Comment #19
amc commentedsubscribe
Comment #20
tadityar commentedComment #22
tadityar commentedTrying to remove those exceptions.