I have a view that uses the Term ID argument. When a user visits the page /posts/all/popular, I would like the title of the view to read "Most Popular Posts". When a user visits the page /posts//popular, I would like the title of the view to read "Most Popular Posts in ".
I set the default title to "Most Popular Posts" and the Term ID argument title to "Most Popular Posts in %1", but when I display the view with the default argument my title either reads "Most Popular Posts in All", or just "Most Popular Posts in", depending on what I put in the Wildcard Title field for my argument. So, how do I get rid of the "in" and get the view to use my default title when the argument is "all"?
I've been searching the issue queue and I came across some related posts, but I couldn't get any of the suggestions to work (or understand half of them, actually). I'm more designer than programmer, so if someone could explain what's required to do this in plain English I'd appreciate it. Is there a function I can put in my template.php file? Is there a function I can put somewhere in the view itself?
Comments
Comment #1
merlinofchaos commentedThere's no way to have a title differ based on the argument, I don't think. Perhaps you could do something in the argument validator with php code where you do a display->set_option('title') but I'm not sure that would work.
Comment #2
jstollerAfter some more digging I came across #365418: Setting the View-Title programmatically in Views2, which lead me to a possible solution:
Is there anything inherently wrong/questionable with this solution? Is there a better way to do this? If you don't see any problems with this than I recommend adding it to the documentation for Views.
Comment #3
dawehnerI don't think that support question can need review :)
If it works fine, thats perfect :)