Closed (fixed)
Project:
Views (for Drupal 7)
Version:
5.x-1.6
Component:
Views Data
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
4 Jun 2007 at 09:52 UTC
Updated:
17 Jan 2010 at 01:26 UTC
I'm using Views to display a table on a page with the data based on arguments passed via the URL. (The arguments are Taxonomy terms.)
What is the easiest way - using PHP if necessary - for me to change the page title to reflect the selected argument passed via the URL. For example, when someone goes to the page with all the types of shoes listed on it, the page title would become shoes.
Thank you.
Mitch
Comments
Comment #1
merlinofchaos commentedIn the 'title' field of teh argument, you can use %1, %2, %3 (etc) to put the argument used in the title.
Comment #2
mwander commentedmerlinofchaos,
As you can probably guess, I'm a bit new to this - and trying to maximize my use of Views.
Is it possible for you to explain this a bit differently or in more detail, please? I've read all the Views documentation. I understand how to obtain arguments from the URL - and am doing that for the Taxonomy terms.
I'm not sure what to do in order to set the page title, Do I need to add code somewhere?
Thank you for your patience with me.
Mitch
Comment #3
add1sun commentedmwander I'll take a crack it. If you look at the Title field in your *Page* section of editing the view you will see it says this: "The title that be shown at the top of the view. May be blank. This title ignores arguments; if you want your title to take arguments into account, use the "title" field in the arguments section."
So, what you need to do is go down to the *Arguments* section and in the argument's Title field you would put %1, %2 or whatever. You can even include other text here so you could have the Title say "All about %1" (without the quotes) or whatever.
Comment #4
mwander commentedadd1sun,
Works like a charm. Got it. Thank you!
And, I'm sure merlinofchaos appreciates that you resolved an issue on his behalf. :-)
Thanks again!
Mitch
Comment #5
(not verified) commentedComment #6
niklp commentedThis is grand, and works just fine - however, whereas my previous text-based title appeared in the breadcrumb trail, the argument-defined one now does not...
Is this by design, or what? Or is there another way to set them...?
Comment #7
merlinofchaos commentedThe title being used for the current page shouldn't appear in the breadcrumb trail. The title for the page above (i.e, with no argument) should appear in the breadcrumb trail.
So if you put a title in the regular title section, and have 1 argument; if you go to that page without an argument, that's the title you'll get. If you go to the view iwth an argument, you should get the link to the page we were just on in the breadcrumb trail. If you do not something isn't working right.
(Note that setting the argument default to 'page not found' will eliminate it from the breadcrumb trail again, since it tries not to link to a nonexistent page.)
Comment #8
michelleAnswered by merlinofchaos 2 months ago and no further questions added. Closing.
Michelle
Comment #9
doublejosh commentedThis (fairly straight forward and long standing) technique has stopped working for me :(
The argument title in view in "Gallery %1", while using Taxonomy Term, and out comes "Home" as the title. Wacky.
I am using Page Titles module, but that hasn't caused a problem in the past.
How might I track down what is robbing me of my nice views arg titles or if there is a bug?
PS: I tried to use this snippet to solve the problem for a bit, however the title is still not able to be set here... even though I've confirmed the arg is being collected and is ready to go.
Comment #10
michelleI would try disabling page titles to see. That module causes that same "Home" problem with CTools so it wouldn't surprise me if it was at fault.
Michelle
Comment #11
doublejosh commentedThanks Michelle. That did it, however I have definitely had Page Title work fine with Views arg titles on other sites.
I thought it might be a weight issue, but Page Title = 0 and Views = 10, so views should be able to set the title after.
Guess it must be a third module that caused the problem between those two???
Bummer.
Appropriate titles is definitely more important than easy to configure spacers and title order, so page titles will have to go for now.
Comment #12
doublejosh commentedFound out this was fixed in Page Title 6-2.3 here: http://drupal.org/node/529186
Turns out it was a Token caching issue. It grabbed the cached token too soon.