Drupal: Customizing the "more" Links in Views
Everytime I have to dig a little deeper into the views module, I'm always more and more impressed with the thought that went into the module by Earl Miles and the other authors. A recently had a request from a client to modify the "more" link that is shown at the bottom of blocks that are generated by views.
I first checked the "edit view" page to see if there was an option for alternate text - there wasn't. Since I was themeing the view, I checked the view-name.tpl.php file to see if it was exposed - it wasn't. After a little more searching, I realized that the views module was way ahead of me - the "more" link was exposed as a theme function. Sweet. I simply overrode the default theme function with my own (I was using the zen theme at the time):
function zen_views_more($url) {
if (stristr($url, 'coolview')) {
return "<div class='more-link'>" . l(t('View all the cool stuff'), $url) . "</div>";
} else {
return "<div class='more-link'>" . l(t('more'), $url) . "</div>";
}
}
if (stristr($url, 'coolview')) {
return "<div class='more-link'>" . l(t('View all the cool stuff'), $url) . "</div>";
} else {
return "<div class='more-link'>" . l(t('more'), $url) . "</div>";
}
}
As you can see, I only override the default "more" text if the $url contains "coolview" - the Drupal path to my view. A clean and elegant solution to the problem which can be easily extended to other view blocks.

Find out base url
hai michael
First i must thank you to post the more link
i am new to drupal and i am using drupal 5 and my problem is how i can find the $url .. . (i.e Coolview) ... i dont how to give $ url please Explain to me ...
Advance thanks
please Give me reply as quick as possible its urgent ;(
Thanks
Muthuraman
You need to override the
You need to override the theme function in your theme's template.php file.
So, if your theme is called "coolview", the theme function example I show above will be:
function coolview_views_more($url) {
-mike
Something else in Drupal6?
Hi,
i was just trying to override the hook in Drupal 6 and it seems your version does not work.
The $url parameter that is begin passed is already formatted as a correct internal link so it is not necessary to use the l() function.
Instead, you should write out the html:
"".t('more link').""
Drupal 5
The article was written for Drupal 5.
Here's how to do it in Drupal 6: http://drupal.org/node/369698
-mike
Maybe its enough to just
Maybe its enough to just provide a footer text for your view with the link to the page. This will also be useful if you want to link to somewhere else outside the view (e.g. another view).
@admin: If there is an error in the form you will get a warning and the input field will be highlighted. But the background of this field has almost the same color as the text.
thanks for the tip on modifying the more link
Really helped implement some last minute "tweaks" from the client.
missing something
I can't find documentation for this function anywhere. Exactly what I'm trying to do. But it doesn't work for me either. I put it at the end of my template.php file for my subtheme.
Panels can trip you up
panel panes have their own "more" link that can mess you up quite quickly...
It works great once I let the view handle the link and not the panel.
Angus
Not working
Its not working. Does it have any problem with sub theme in zen???
It shouldn't - just be sure
It shouldn't - just be sure you're adding the override function to your subtheme's template.php file.
-mike