By thejerz on
Currently printing primary links like this in page.tpl.php:
<?php print theme('links', $primary_links); ?>
Instead of $primary_links returning just links, I would like a unique icon (path to jpg on the server) to be associated with each link. How can I do this?
Comments
Use CSS
As of Drupal 5, all menu lists have unique class names, as do the contained list items and links. You can target a specific link in your CSS and assign it an icon as a background-image.
Do you know how to approach
Do you know how to approach the h2 title? It's been hard for me to place an image for each one, i want each of them to look different. They dont have a unique id to apply css.
Any ideas? D5.
Tecito.com
Comunidad Latina en Canada, regístrate ya! Join the growing latin community in Canada.
Idenitify the block ID
No, but every block has a unique id, so assuming you only have one h2 tag in a block, you can target that.
Kinda opened my eyes a bit
Kinda opened my eyes a bit more. I am gonna do some search on how to target h2 in a specific block. But what if i have more than 1 block, and both blocks have the same h2? Mmmm....
Thanks for the tip.
Tecito.com
Comunidad Latina en Canada, regístrate ya! Join the growing latin community in Canada.
How do I go about
How do I go about identifying these unique class names?
unique #id and still not clean
Yes, thank you! Drupal 5 does have unique #id's for the primary links. Every time I change my primary links, I would have to change the CSS. This is not very desirable.
What I would like to do is associate an icon with a page or book node; this way, the image is linked to the node, not a css id. Then, in your theme, depending on what you need, you could just insert an icon, a title, or both. Doesn't that make more sense? I hate to swear on these forums, but doesn't Mambo / Joomla / This Month's Name have support for an icon for a page. Of course, limited in 10000000 other ways...
Any support for ICON attribute of every NODE?
silly choice, I agree
A fine CMS to its 6.2 version and I'm trying to understand how to put an image on a menu link...
I think this SHOULD be a core feature because to make a cms useful you need some sort of abstraction about what a linking item is and how it is represented apart from the template style.
My explanation: a link can be a text string as well as any image or whatever, I saw many posts from version 4.7 on and nobody cared about that. And this is because an icon can visually express some idea about the semantics of the content it links, that shouldn't be done statically via a template or css that just organizes the layout.
Even in 6.2 the logic of primary links is a bit tricky to extend, the capability would be to assign an icon (ora set of) to every menu item and store it on the DB to really abstract what a menu item is, so there should be more fields on the menu form to access this feature.
I freshly built a website and I was very happy about drupal before being stuck in this icon thing. I used joomla (who supports icons in menu but the result depends on template settings) and mdpro before and the problem is always the same: some of the logic is in the template and I'm back again in this strange-template-structure-modify-something incubus just for a feature which is basically any website's need. sigh :(
unique ids for primary links in 4.7
Running 4.7 still due to web server restrictions and general fear of recent releases... That said I would love to use a line of php to assign unique ids to my primary links (which I've got as images, used the snippet at http://drupal.org/node/62149, works great, it's below).
Can anyone help me find an efficient snippet to do this? Seems like it should be relatively simple with a little more php knowledge than I have, no?
Primary links reference in page.tpl.php:
Another solution
I modified the approach in http://drupal.org/node/110199 so that I can replace a menu name with an arbitrary image as follows:
In template.php, instead of rewriting theme_menu_item_link(),
rewrite theme_menu_links() as follows: