The title of the term page is not configurable; it is always the term name, even if the term name display is "hidden."

This is a problem for one of my projects, where I need a descriptive page title based on the term name. For example, I have a vocabulary "Committees", and within that vocabulary "Budget", "PR", etc. The "Budget" term page should be titled "Members of the Budget committee," not simply "Budget."

If I select the Views display method, I would love for the title I specify with Views to be used.

I am attempting to develop a patch. Any hints on an implementation strategy?

Comments

ezheidtmann’s picture

Title: Term page titles are not configurable; even Views page titles are not used. » Request: Configurable term page titles; use Views page title.
codycraven’s picture

Category: feature » support
Status: Active » Needs review

ezheidtmann,

You should be able to alter $term->name in hook_taxonomy_display_term_page_term_object_alter() to achieve this.

damontgomery’s picture

I don't want to hijack this thread, but I've been struggling with this for a while and while taxonomy_display got me most of the way there, it just didn't go all the way.

http://drupal.org/sandbox/derhasi/1177152

This in development module fixed all my issues. I've got a "news" view which can be accessed through http://www.example.com/news/5 (for term with id 5). This other module allows you to fill in a field on the taxonomy page to redirect all links to "news/[term:tid]" from "taxonomy/term/[term:tid]".

Since this is a redirect to the actual view, all the custom titles used by views will hold. It's just like going to http://www.example.com/{your_view_name}/{term_id}.

(note: if you are not used to git, which you will need to download that in development module, install git and open gitbash. This is a command line tool. Then enter the text listed on the Drupal page above. This will download the module to the taxonomy_path folder from which you can install as any other module.)

I know that taxonomy_display does more than this other module, but for my simple (yet common) needs, this worked well.

ezheidtmann’s picture

Status: Needs review » Closed (won't fix)

pandaeskimo, I'm using taxonomy views switcher now instead. It is simple and easy to configure, relying on url aliases (most often pathauto) to choose the view. Titles and everything is handled by the view.

http://drupal.org/sandbox/simg/1106944

jeffschuler’s picture

Category: support » feature
Status: Closed (won't fix) » Active

I see this as a feature request, as originally posted. If taxonomy_display can hand rendering over to a view, it should also allow the view to handle the name of the page.

jeffschuler’s picture

Also, @codycraven editing $term->name in hook_taxonomy_display_term_page_term_object_alter() is not changing the title displayed.

codycraven’s picture

Title: Request: Configurable term page titles; use Views page title. » Request: Configurable term page titles
Version: 7.x-1.0-rc4 » 7.x-1.0
Assigned: Unassigned » codycraven

I think instead of receiving the page title from the view we should instead add similar functionality to the taxonomy display form. The reason being is with several requests like this we could easily create a racing condition.

The views configuration doesn't actually have that much functionality and it is something that I can see as being a worthwhile addition.

jeffschuler’s picture

Thanks @codycraven.

That solution would work fine for me, currently, as long as I can use the taxonomy term name token in the title.

Still wondering why my hook_taxonomy_display_term_page_term_object_alter() implementation isn't working to change the title. I can open another issue if you want, but is this where you're suspecting a race condition of multiple modules trying to set the title?

codycraven’s picture

jeffschuler, I'm working on a solution, however I think I'll need to run some stuff by the i18n developer so there may not be a quick solution on the module release front.

Regarding the hook your code should be working, ensure you have the following format for you hook implementation:

/**
 * Implements hook_taxonomy_display_term_page_term_object_alter().
 */
function MODULENAME_taxonomy_display_term_page_term_object_alter(&$term) {
  $term->name = 'My prefix: ' . $term->name;
}

If it's not working you likely have another module which has hijacked the taxonomy/term/%taxonomy_term title callback such as Panels.

jeffschuler’s picture

Thanks. That's what I suspected. I see the change happen within the context of the function but it doesn't make it to the page. Maybe Display Suite...

codycraven’s picture

Status: Active » Closed (won't fix)

Jeff, after trying to get this to work I've determined the only way to fix the issue is to modify the module's weight in which case I will force hijacking of the menu's title entry over other modules (such as panels which should have priority).

I could see creating this as an optional sub-module in which it shows up within the taxonomy display form... which may be the best option.

Right now I'm marking this as closed (won't fix) if you would like to see this functionality as a sub-module, or a dependent module, please re-open to active and I'll evaluate whether to create a sub-module, or a new project, then begin work on it -- I don't want to develop something people don't really need nor want, so I'm doing this really to show that there's continued interest.

If you can think of any other alternatives let me know.

valderama’s picture

Status: Closed (won't fix) » Active

Hey codycraven,

I'll reopen this, as it seems that the solution you suggested in your last comment, seems perfect to me. The solution as a submodule would be best, as it seems a lot people expect to be able to change the title as well.

An option to use the title from views module would make sense, I think.

I could also help, if you like to mentor a bit (I have module dev experience, though)

Thanks and best,
walter

codycraven’s picture

walter,

I'll take you up on the offer! Thinking about this I kind of think this should be it's own standalone module (taxonomy_title?). As this feature could definitely be useful to sites that don't have a need for taxonomy display.

If you're serious about developing the module I'm more than willing to mentor and contribute (with my limited time). I'd also like to link to the module on the taxonomy display project page.

Drop me a line on my contact form so that we can establish communication outside of the issue queue.

For now I'm going to re-mark this issue as closed won't fix as I think a separate project will be most useful to the community.

codycraven’s picture

Status: Active » Closed (won't fix)
-Mania-’s picture

It's a shame the page title from the view doesn't work. Until then I've tried the hook in #9 which works but it is a global override. How would I alter it to have a different term title for a specific vocabulary?

Edit. Got this working:

/**
* Implements hook_taxonomy_display_term_page_term_object_alter().
*/
function MODULENAME_taxonomy_display_term_page_term_object_alter(&$term) {
  if($term->vocabulary_machine_name == "VOCABULARY_MACHINE_NAME") {
    $term->name = 'My prefix: ' . $term->name;
  }
}