0

I know that you can get the arguments in the view's title and format it so that it makes sense so that an argument like "search-for-something" can be output as "Search For Something".

I have an argument passed like "argument-here" and I need to search in the database for that exact phrase.

The problem is that in order to get it to format nicely in the title as "Argument Here", this also removes the dash in the SQL query - resulting in nothing for my view to return.

Is there a way that I can format the result for the title without messing up the actual argument for the SQL query?

2
  • I'd recommend restoring the view so the query works properly and then working on the title after that. How are you generating the 'clean' title?
    – Entendu
    Commented Aug 30, 2011 at 19:12
  • I'm simply using the options provided by views - when you edit the argument options, I am passing the argument into the title using something like "Listing of %1". I can modify how it appears using the "Case" options and the "Transform spaces to dashes in URL". The transform option is the one causing the issue. If I want the title to appear without dashes, I must check this, but then it removes the dashes from the argument before passing it to the SQL query which is what I DO NOT WANT.
    – oranges13
    Commented Aug 30, 2011 at 19:15

1 Answer 1

1

Restore your view so that the query works. Then, make sure the PHP Filter module is enabled and that you have permissions to use it.

In the view, add this header:

<?php
$view = views_get_current_view();
$my_title = ucwords(str_replace("-", " ", $view->args[0]));
drupal_set_title($my_title);
?>

Make sure the input format for the header is PHP.

The view's preview will show the wrong title. That's ok. When you navigate to the page, you'll see that the title is as you want 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.