Overriding TITLE tag content for category/taxonomy "pages"

insite2000 - February 4, 2008 - 19:40

We have a site set up so that we have "hub" pages, which are actually categories/taxonomies that have been aliased. For example:

http://dev.spine-health.com/Arthritis.html

(I set up guest access - username: guest, password: 7spine-y*X3

where "Arthritis.html" is not a node, but an aliased taxonomy incorporating articles from its related category.

The question I have is this: I know how to override the page title for a node, but how do I handle this for an aliased taxonomy page? It's giving me fits...I don't want the TITLE tag content to read "Arthritis," rather I want it to read something like "Arthritis symptoms, causes, diagnosis and treatment." I've been through everything I can think of to make an override happen on these "pages," and I'm sure it's something simple, but I'm not finding it.

Additionally, our site name is auto-populated in the title, which I don't want. I think that is a "site slogan" that I can remove in admin/site config, but if I'm barking up the wrong tree will someone please let me know? I know just enough to be dangerous with Drupal, but not good enough.

I think using the Views

Blackguard - February 4, 2008 - 20:01

I think using the Views module would be your best best instead of an alias. It is daunting at first, but the effort is worth it many times over.

Install the views module.
Create a new view (add).
Create a page view (click provide page view), set it's url as Arthritis.html
Choose teasers as view type.

Write the title you want in the title field -> Arthritis symptoms, causes, diagnosis and treatment.
Use pager. Choose your number of nodes per page. You'll have little page numbers at the bottom of your page when viewing it if you have a large number of nodes.

Go down to Filters. Choose the taxonomy term you want.
You might also need to add a node type, but I'm not sure - just the taxonomy term might suffice.

Include a sort criteria if desired.

Save it, visit the URL, and be merry!

Re: Overriding TITLE tag content for category/taxonomy "pages"

progga - February 4, 2008 - 20:36

The taxonomy_term_page() function of the taxonomy module creates taxonomy-based listing. This function is not providing any themable function, so I can't find answer to your first question :-( Considering this, BlackGuard's suggestion is a good one IMHO.

Regarding your second question, you can do these from admin/settings/site-information.

You could do what Blackguard

archard - February 4, 2008 - 21:13

You could do what Blackguard suggested, but you can also take it a step further by using the taxonomy_term view that comes with the views module. With this enabled you can change the look of every taxonomy page, and with some php code you can alter the title of any term page you want. I explain how to do it in this node: http://drupal.org/node/216065

You could put something like this in the header box:

<?php
$name
= drupal_get_title();

$term_name = taxonomy_get_term_by_name($name);

if(
$term_name[0]->name == 'Arthritis')
drupal_set_title($name . " symptoms, causes, diagnosis and treatment.");
?>

Wow I'm bookmarking this!

Blackguard - February 5, 2008 - 04:16

Wow I'm bookmarking this!

Tracking for

hagrin - February 5, 2008 - 05:15

Tracking for later.
_______________________________________________________________________________
http://www.hagrin.com - Just my little slice of the Interweb

archard, is there a way to

akahn - March 3, 2008 - 16:16

archard, is there a way to override the heading on a views-based taxonomy (a custom view, not an override of taxonomy_term) listing page? I have a vocabulary "news" with one term in it, "yes." This makes it really simple for my client to decide which nodes should appear on the news page. But at the top of the news page, it says in large letters "Yes," since this is the term name. Using the page fieldset's title field doesn't seem to have an effect. How can I override this header to say "News"? Thanks for any help.

Really useful

dejbar - April 2, 2008 - 05:58

Thanks a lot this is really useful. I never knew you could change stuff like this from the HEADER.

I had a look at the docs for drupal_set_title() and it says it sets the title for both "page" title (i.e. the thing in the <title></title> tags) and the title in large writing that appears on the page. Is it the case that these are identical in drupal? Is there any way to control them independantly in views?

I don't know, there's

archard - April 2, 2008 - 13:26

I don't know, there's probably some API function that can set them independently, check it out

http://api.drupal.org

Vocabulary Name / VID

undoIT - March 12, 2009 - 21:18

Is it possible to do something like this but based on VID / Vocabulary name so that if somebody is viewing a term within a vocabulary, the title will be changed based on the vocabulary pattern?

For example, if you have a Vocabulary called "Blue" with a term under that Vocabulary called "Orchids" and wanted to add "Blue" to the title for all terms under the Blue vocabulary, is there a way to do this so that the title would read "Blue Orchids" etc...?

These are great suggestions!

insite2000 - February 5, 2008 - 00:23

These are great suggestions! Not sure which one I will use, or potentially both. Thanks everyone. :-)

--------------
DJ Scootch

"The reason why worry kills more people than work is because more people worry than work." -- Robert Frost

I don't know if I explained this right....

insite2000 - February 10, 2008 - 22:12

I don't think this is what I want...either that, or I'm just not following. The latter is more likely.

The page I have right now at http://dev.spine-health.com/Arthritis.html is taxonomy with a URL alias. All of the blocks that you see on that page are assigned either via regular expressions or via "inculde only on these pages" list within the block itself.

I need this *exact* page, but I need to be able to set the title.

So how would I set a view and basically just make it display what I have at this taxonomy? If I can do *that*, it would be perfect because I can set the title within the view but the "page" (taxonomy) will display all the navigation and content blocks just the way they are now.

I'm so confused....

--------------
DJ Scootch

"The reason why worry kills more people than work is because more people worry than work." -- Robert Frost

I think this could work -

Blackguard - February 11, 2008 - 21:22

I think this could work - you'll have to try it out.

You can name the URL for your view

Arthritis.html

Your views will use arguments as such

Arthritis.html/[tid]

Try putting your visibility settings in your blocks to

Arthritis.html/*

This is just guesswork, but if it works, your problem might be solved.

Took a completely different track....

insite2000 - February 13, 2008 - 20:57

This was all awesome advice, but the views module ended up hosing our taxonomy breadcrumbs and that was too big an issue to overcome. I had to disable views.

We wrote a hook that takes the description from administer-->content management-->categories-->term description and plugs it into the TITLE tag for page-taxonomy-term.tpl.php.

Still, I really appreciate everyone's ideas and it helped me learn a little more about the CMS. Thanks!

--------------
DJ Scootch

"The reason why worry kills more people than work is because more people worry than work." -- Robert Frost

Could you share plz?

ethanre - April 12, 2008 - 20:46

insite2000,

Thanks for posting what actually worked for you.

I was looking exactly for this, could you please post the hook you created to add "page title" to taxonomy pages?

Thanks
Ethan
UT

me too!

miahawk - April 4, 2008 - 20:36

yes, please share. I've been searching for a way to do what you've described!

me three

fletch11 - April 23, 2008 - 13:03

it would be really useful if you could post the snippet you used. Thanks for the post.

Sorry :-(

insite2000 - May 30, 2008 - 05:55

Hi gang,

Unfortunately, the folks at Spine-Health.com didn't renew my contract, so I no longer have access to that code. I do remember that it was a matter of "borrowing" the content from that text box and doing a dynamic insertion in the title tag of the header file by echoing the variable value. Wish I could remember & give you more but it's been awhile since I was there.

--------------
DJ Scootch

"The reason why worry kills more people than work is because more people worry than work." -- Robert Frost

DJ, I would be willing to

thill_ - October 10, 2008 - 17:15

DJ,

I would be willing to pay for you to recreate this for me. let me know please

timh4982 at gmail

I wrote a module that does exactly this

jenlampton - November 10, 2008 - 21:57

@thill_

I think what you want is the Page Title module.

Jen

This may be more like

mrtbc - November 16, 2008 - 16:01

This may be more like it:

http://drupal.org/project/title_rewrite

or this...

jenlampton - November 17, 2008 - 19:55

Subscribing, greetings,

Summit - January 15, 2009 - 14:48

Subscribing, greetings, Martijn

 
 

Drupal is a registered trademark of Dries Buytaert.