Replacing a 'read more' node link

abrabapupa - June 15, 2009 - 22:12

Hello there,

i found that it's nearly impossible to alter the 'read more' link (line when displaying node teaser).
I want to simply replace it with nice image and title, instead of a textual link.

I tried to implement following functions in my template.php file:

mythemename_link(..) - never called
mythemename_link_alter() - same

the only hook which is available is

mythemename_links()

but altering a link in this function is a bit awkward

function mythemename_links($links, $attributes = array('class' => 'links')) {
if (isset($links['node_read_more']))
{
          $links['node_read_more'] = ....
}
return theme_links($links, $attributes);
}

is there a more elegant way?

what about the read more link

coreyp_1 - June 16, 2009 - 00:06

what about the read more link are you trying to change?

-Corey

- Corey

...

Jeff Burnz - June 16, 2009 - 00:23

Yes, there is a much more elegant way, Image Replacement - http://adaptivethemes.com/use-icons-for-node-and-comment-links

IR preserves the text for accessibility and SEO and is a lightweight CSS only solution, no PHP required.

Note that my sites site_name also uses an image replacement technique.

CSS-only text replacement is not always an option

abrabapupa - June 16, 2009 - 21:23

When you need to display icons inline, a CSS text replacement is not quite appropriate solution. Not saying, that this solution fits only for simplest forms - replacing a link text with image. What if i want to display an icon + text? Or make some links to open in a new page etc.

So, i asking second time: is there a more elegant way to modify a way how links markup generated by theme?

If you are wanting to replace

coreyp_1 - June 16, 2009 - 21:55

If you are wanting to replace the text completely, you can always try the String Overrides module.

-Corey

- Corey

...

Jeff Burnz - June 16, 2009 - 22:07

icon + text = background image + padding.

open in new window is a link attribute or js behaviour, nothing to do with what you asked originally.

"a CSS text replacement is not quite appropriate solution", yeah, whatever man, you stick to that ok.

/dev/null

...

abrabapupa - June 18, 2009 - 10:00

open in new window is a link attribute or js behaviour, nothing to do with what you asked originally.

sure thing, but i cannot predict what customer/designer might want to put there next time. This is why i want a most generic solution. And what is you proposed is very limited one.

P.S. I really wonder, why do i need to use CSS hacks, when i have a direct access to all sources and can modify markup in any way i want it to be.

ed_readmore module

tcvn - June 17, 2009 - 13:38

Have you tried using http://drupal.org/project/ed_readmore module yet?
tcvn

Just what i looking

abrabapupa - June 18, 2009 - 09:52

Thanks for pointer!
This is yet another thing which i wanted to fix among other things related to 'read more' link itself.

 
 

Drupal is a registered trademark of Dries Buytaert.