Skip to: Site menu | Main content

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.

Default 'more' link

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>";
  }
}


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.

Improved 'more' link

Submitted by michael on Fri, 07/20/2007 - 4:21pm.
Filed under:

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <table> <tr> <td> <th> <div> <span> <p> <br> <blockquote> <hr>
  • Lines and paragraphs break automatically.

More information about formatting options

Please wait...
He that can have patience can have what he will.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.