I've set up a page view with a path of 'services/communication/%' the '%' being a contextual filter of 'Content: Title'.

The problem with this is that the url ends up looking something like 'services/communication/Best Practices'. In the contextual filter I have set the case to 'lower case' and checked the box to 'Transform spaces to dashes in URL', however, neither of these things are doing anything.

In most cases the link to some content works fine but if there is a dash in the content title (e.g. 'online-led reporting') the content won't display.

How can I use an aliased content title with the contextual filter?

  • the dash issue is one of those thorny ones in that views will, if asked, transform all spaces to dashes or all dashes to spaces. So, in your example, online-led reporting becomes online-led-reporting in one direction, but then becomes online led reporting in the other, and then, it can't be found because you're really looking for online-led reporting
    – Jimajamma
    Feb 20, 2012 at 7:59
  • @Jimajamma Ah yes if I uncheck that 'transform spaces' option it will display the content. However, it's still annoying to have spaces in the url. Is there any way of using an aliased content title with the contextual filter? Obviously pathauto will do this but how can I use the alias it creates in Views? Feb 20, 2012 at 10:12

1 Answer 1


How I attacked the spaces/punctuation issue ( http://drupal.org/node/786612 ) in Drupal 6 was by creating a url_safe_title text field and putting it in any content type that needed to be looked at, searched for, etc by it, and then having nodeapi() "fill it in for me" like this:

function MODULE_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
  if (isset($node->field_url_safe_title) && $op == 'presave') {
      module_load_include('inc', 'pathauto');

You can get fancy and hide the field with permissions, css etc so your users don't see it when creating content. I use http://drupal.org/project/nodeformcols to hide it and hide it from $content on display, too.

So, what this does is change simple titles like Hello World into hello-world but also online-led reporting into online-led-reporting with the added/needed benefit of being able to get back to "online-led reporting" from it. It also helped out with stuff like Kukla, Fran and Ollie that turned into kulka-fran-ollie :)

So now in Views I use this field instead of the node title when I needed to grab things. Just have to be aware of uniqueness, but that's another story in of itself :)

  • Thanks for your response. I'll have to look into this more closely when I get a chance. I'm not so familiar with the Drupal API. Feb 22, 2012 at 20:54

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.