By divrom on
I'm coming from a Wordpress background, where many of the templates have (pointless) icons next to much of the post metadata. E.g. a pencil for "written by" or a small clock next to the time/date, etc.
Though I don't want to clutter things up that much, I do want to add a small speech bubble next to "Add comment" and a Printer icon next to "printer-friendly version", etc. How would I go about this? I'm not even sure how to break down $links, let alone discovering what I would replace that with!
Thanks for any help you can give.
Comments
CSS
Give CSS a try..
Check if the links have classnames or ids, if not, check where they are.
Then attempt to use css and a background-image with some margin or paddings to play with positioning of the text (if the text is needed).
If you want to completely remove the text and swap it with an image, you can display the link as block, then text-indent: -10000px; to hide the text.
does this help?
Tip: use Firefox with the Web Developer Extension.
You'd think so wouldn't you?
Thanks, Steve, but that's the first thing I tried.
I'd noticed this on 1 or 2 other sites, so I figured that's how they did it; but there are no classes in sight.
So, all I can think is that I need to break open the $links, or find somewhere else to add classes. Any ideas?
it is posible on css
it is posible on css
thanks for this post
thanks for this post "then text-indent: -10000px; to hide the text." was nice to learn
hiding the link text ?
This works to hide the link text, but the display: block creates a linebreak before and after the icon.
Does anyone know how to do this without inheriting the linebreaks ?
... I want all my icons in a row ;-)
try this if you wanted to
try this if you wanted to replace it with a graphic and remove the text:
---
I work here: Raincity Studios.com
I hang out here: Steve Krueger.com
---
I work at The Jibe Multimedia, Inc., a Vancouver Drupal eCommerce Web Agency.
Not easy, but possible
As far as I know, there is no easy way to do this.
But I am doing it for the 4.7 version of my Sands theme (I can never stop plugging it...). I'm doing it the niave (and probably slow) method of just rewriting $links in the corresponding theme function to have classes and IDs, i.e.:
I've yet to do benchmarking on how slow this is... But it certainly looks good.
You can see the theme in development at my personal homepage. I've yet to commit this code to CVS but will do so when I get time.
__
Personal home page | Rhombic Networks: Drupal-friendly web hosting
That looks really good,
That looks really good, Samat. Thanks.
So, what is the file that you're putting that code into?
template.php
template.php, forgot to mention.
__
Personal home page | Rhombic Networks: Drupal-friendly web hosting
that does look good.
that does look good.
this is something we need and I can see myself needing this in the future as well.
where do the icon files go?
i am a very new drupal user but i'd love to try this, but where do i upload the icons?
i noticed that there are some icons in the misc directory, do i put them there?
thanks guys!
"icons" directory in theme directory
For the code I have above, inside a directory called "icons" in the themes directory.
I've these icons incorporated into my themes Sands and Sands_CSS. You may want to look at them for examples.
__
Personal home page | Rhombic Networks: Drupal-friendly web hosting
Thank You!
Thank You Samat for posting this. You made my life easier. EXCELLENT JOB!
Your explination for not doing it 'other ways' was also beneficial. Mainly because that IS the way I was going to do it, but decided first to check the forums.
I've stuck this in my
I've stuck this in my template.php and it doesn't appear to make any difference? Is there something that needs to be called somewhere else to get it to go?
Function name wrong?
The function is called "sands_links," so it will only be called if your theme is called "sands." If your theme is named blah, the function needs to be named "blah_links."
__
Personal home page | Rhombic Networks: Drupal-friendly web hosting
That's got it!
I had changed the function name, but I didn't realise it was tied to the theme. Looks like it's working now, thank you :)
add classes to delimiters
Can u please tell me how to modify this code to display classes for delimiters and links. I would like to add something like span class=icon-$id to delimeters.
edit:
ok i just added
$link = str_replace('</a>', "</a><span class=\"del-$id\"> | </span>", $link);so my code now looks like this:
i also saved template.php in utf-8 format to allow nonenglish characters.
www.ferjan.net
I don't understand
I have a site and i do it completely in css
Daniel Garcia Peña
for example
Not representative
You've only styled one link--many other links do not have classes or IDs (e.g. add comment, etc).
__
Personal home page | Rhombic Networks: Drupal-friendly web hosting
4.7 hack to add icons next to comments and read more links
I'm pretty new to both drupal and php, so I'm not sure if this is the most elegant hack in the world, but it seems to be working for me.
I changed the common.inc 'l' function to check the $text field, and send an image back in the return if it found certain keywords.
so, somewhere around line 1511 of common.inc, instead of just...
...I've now got...
to remove the text part of the links and just leave the icons, just drop the . ($html ? $text : check_plain($text)) . bit from the relevant lines.
obviously, you run the risk of a non-comment/readmore link that has those keywords in the $text variable, and thus icons turning up where you don't necessarily want them, but I think with a bit of fine-tuning it'd probably do the job required reasonably well.
I think, in fact (I've just been playing with this code this afternoon, so it's even evolved as I've written this post), that you'd be better off using the title text that gets sent, ie the "Jump to the first comment of this posting", "Add a new comment to this page" and similar that get passed to the l function as part of the $attributes array. Hmmm.
Anyway, I've got this code running on my site (still under heavy development) - wellingtonista.com
I think the l function is a
I think the l function is a called quite a bit, so I'd avoid making the code there any more loaded than necessary.
--
Bradlis7.com | Churchofchristnet
indeed it is, but I wouldn't
indeed it is, but I wouldn't have thought adding an if..elseif...elseif..else in there would have added too much in the way of processing overhead.
anyone know of a way of testing page processing speeds so i can test this with and without the hacked code?
...
developer module tracks processing times etc : http://drupal.org/project/devel
Modifying core Drupal files not encouraged
Generally, modifying core Drupal files is not encouraged, because it makes upgrading a pain. Granted, the "l" function will probably not be changed anytime during the 4.7 release cycle...
__
Personal home page | Rhombic Networks: Drupal-friendly web hosting
useful thanks
I've just used this to style $links in a more granular fashion, thanks for the tip and good work with sands_css!
---------------------------
Managed Drupal hosting from Ixis IT
Swapping $links for icons in drupal 5
Ok, I know its easier to do this in Drupal 5. But for newbies like me, here are some instructions to help you get started.
Background
In your code drupal
theme.incfile, look forfunction theme_links. This is just to give you an idea. Please do not update / delete / modify this function. Ok? :)In this function, you can see the following code (or atleast I think this is the relevant code)
What this is doing is to add class parameters to each link which you can now style using CSS! Hooray!
What you want to do to add the icons
If you enable comments for nodes (say blog entries for example) - go ahead and add a blog entry and then publish it. Once published, look at the node and do a view page source... on it. Look for the following code
So now to add an icon for Add new comment text, you can add this to your style sheet for the class="comment_add"
Note that the icons directory is within the relevant theme.. so its
drupal/themes/yourtheme/icons/nameoftheicon.jpgKeep adding this for every class you see at the top .. e.g. you can add the css for
subscriptions_add_blog,subscriptions_add_nodeetc etc.Hope this helps.
one thing missing
you'll need to add an anchor ( "a" ) to each class to prevent the icons from doubling up.
for example:
... and so on.
What if I want to replace
What if I want to replace the TEXT itself? I am using 5.1, and would like to not just add an icon, but replace the text using the template.php file. Specifically the book 'printer-friendly page' text.
Thanks, Maria
Advice from a newbie...
I'm sure there's a way to do it in the CSS for each them, but if I can't do it there, I plan on hacking into each of the modules and replacing the text they send as a link with a space. Help anyone?
Custom Links
check out the Custom links module. This will allow you to attach links based on the specified content types. ex: I want a "LISTEN TO ME" link on all my postcast content types.
---
I work here: Raincity Studios.com
I hang out here: Steve Krueger.com
---
I work at The Jibe Multimedia, Inc., a Vancouver Drupal eCommerce Web Agency.
That didn't do what...
...I wanted to do. I checked it out and either I didn't understand it, or it didn't do what I wanted done. I wanted some of the links with just icons, some just text, and some with icons and text.
I got the desired effect by hacking into each of the modules and deleting the text where I wanted only an icon. I'm almost there. Now I just have to figure out how to order the links to my liking and then find a way to put the Read More link at the end of the text as Continued...
Thanks to all who gave great advice here and thanks to SteveK for taking the time to help.
subscribe
Is there a easier way for
Is there a easier way for drupal6?
-----------------------
Join the community!