I have a custom content type called 'Project' that contains a field called 'Category' of type 'List (text)'.

I have created a custom view block that selects all category fields in Projects and used a contextual filter to 'Display a summary', so the block contains an unordered deduped list of the categories.

The block is loaded into a region in a custom template, and output in page.tpl.php using

print render($page['other_menu']);

Unfortunately, the URLs in the menu appear in this form: href="/projects/Culture-%26-Leisure"

I need them to be all lower case and replace -%26- with an underscore like this: href="/projects/culture_leisure"

I can make this happen using preg_replace(), but suspect it's possible to have the view output the URL in the format I require. I just can't figure how to make the view do this.

  • 1
    Boy it's hard to figure out quite what you're trying to do here. You need to get the links sorted out in the view rather than trying to do it on output. Why do they need to change?
    – drewish
    Dec 2, 2011 at 14:25
  • Wazza, on this site, if you think the answer is good you can acknowledge it by clicking the up arrow. If you think it is correct and accept it, click the checkmark. :)
    – Ashlar
    Dec 3, 2011 at 2:17

1 Answer 1


If I can reverse engineer what you are doing, am I right to assume that you have a project with a title of "Culture & Leisure" that you want linked to /projects/culture_leisure instead of "/projects/Culture-%26-Leisure" ?

If so, on Drupal 6 at least, this looks like a quick change of pathauto punctuation settings as it's the module that changes spaces and punctuation in titles and such into more presentable urls.

Here it's at 'admin/build/path/pathauto' but I am sure you can find it or its equivalent on your Drupal 7 site pretty simply.

There, just look for what it's doing with the ampersand and tell it to delete it instead of leaving it alone (which ends up in it being encoding as %26), tell it to use a '_' as the separator instead of a '-' and, last but not least, to also change everything to lowercase.

That should do it :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.