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.

Post new comment