I set a pattern for the taxonomy title and I set the check on the "show field" checkbox.
After that I go to the taxonomy "edit term" page for my term and I try to write a custom title valid only for that term.
I see that my custom title has not overwritten by the module but my page has again the default pattern for taxonomy that I set.

Is this the correct behavior?

I think that the custom title for a term must overwrite the default pattern I set in module configuration.

Have anyone seen this behavior?

CommentFileSizeAuthor
#3 page_title-n654758.patch7.7 KBdamienmckenna

Comments

damienmckenna’s picture

Am having the same problem.

damienmckenna’s picture

Looking at what's going on in the code, I don't see it even trying to load the overridden value for terms (or anything else for that matter) in page_title_page_get_title(). I'll see if I can come up with a patch to fix it.

damienmckenna’s picture

Priority: Minor » Critical
Status: Active » Needs review
StatusFileSize
new7.7 KB

Changing the priority to Critical as this key functionality does not work in 6.x-2.3.

Here's a patch that makes the following changes to page_title_page_get_title():

  • Wrapped comments to a maximum of 80 chars per the Drupal coding standards,
  • Allowed for space for special cases, e.g. the forum root just loads a variable so no need to do any other heavy processing.
  • While identifying the type of object being viewed, it checks if that object can have its title overridden by the user.
  • Additional special case: node titles can be loaded via hook_nodeapi, so load it there.
  • If the object being viewed can be overridden it tries to load the appropriate title record.
  • If no title was found it processes the title pattern as usual.

Also:

  • Fix a bug in hook_nodeapi that would load the page_title even if the type did not allow it to be overridden.

This has allowed the page title to work as intended: if a page title is manually overridden load it first, otherwise use the pattern structure.

damienmckenna’s picture

In the interests of making it easier for beginners, I've bundled the latest code from the v6.x-2.x branch together with my patch: http://www.mc-kenna.com/drupal/2010/01/archive-of-page-title-module-with...

damienmckenna’s picture

FYI this also rolls in the fix from #654672: Invalid title on forum root.

damienmckenna’s picture

Looking at the code again, should the manually configured titles also be processed for tokens? Is there a reason why I can't set the title for a node to "something | [site-name]" and expect it to process the token?

damienmckenna’s picture

I've added a new ticket for processing manually-assigned titles: #689620: Pattern for processing manually-assigned page titles

damienmckenna’s picture

Status: Needs review » Closed (fixed)

An "undocumented feature" in Panels and a page_title misconfiguration was causing this for me.

damienmckenna’s picture

To clarify:

  • When using Panels to customize the taxonomy-term pages you must use e.g. "%term:name" as the panel's title.
  • The overridden page title gets loaded correctly as normal and is assigned as the token "[page-title]".
  • If set the vocabulary's page_title's pattern is set to e.g. "[cat] | [site-name]" it won't pick up the existing page title value as the "[page-title]" token doesn't exist; this includes the overridden value.
jenlampton’s picture

I'd like the field on the taxonomy term page to provide the token substitution for [page-title], but I want my $head_title to print out [page-title] | [site-name] (just like we can do with nodes).

I'm not sure this is possible with the current patch, though I may be mistaken.

I've set my default pattern to be: [page-title] | [site-name].
I've entered in my custom page title text on the term's edit form.

And my resulting page title is only [page-title].
The " | [site-name]" part is missing.

I think the behavior should be the same for nodes and terms, but I'm not really sure how to get there.

techgirlgeek’s picture

Status: Closed (fixed) » Needs work

FWIW, we ended up writing our own token. If the pattern is set, and the "show field" is checked, it will use the custom page_title if set, otherwise it will use the set pattern.

Here's an example of the token we setup:


hook_token_list().
*/
function mymod_token_list($type = 'all') {
$tokens = array();

if ($type == 'taxonomy' || $type == 'all') {
if (module_exists('page_title')) {
$tokens['taxonomy']['mymod-page_title'] = t("Page title because ignores defaults.");
}
}
return $tokens;
}

/**
* Implementation of hook_token_values().
*/
function mymod_token_values($type, $object = NULL) {
$values = array();

if ($type == 'taxonomy') {
if (module_exists('page_title')) {
$term_title = page_title_load_title($object->tid, 'term');
$values['mymod-page_title'] = !empty($term_title) ? $term_title : $object->name;
}
}

return $values;
}

chefarov’s picture

Neither of the 2 approaches work for me.
Firstly I tried from project's page the 6-dev version, then I tried the code from McKenna's site.
Finally I tried added the techgirlgeek's code in my page_title.module file which gave me a WSOD.

jenlampton’s picture

@chefarov the code from @techgirlgeek was missing some comment markers at the beginning. Did you catch that? Try this:

/**
 * Implementation of hook_token_list()..
 */
function mymod_token_list($type = 'all') {
  $tokens = array();

  if ($type == 'taxonomy' || $type == 'all') {
    if (module_exists('page_title')) {
      $tokens['taxonomy']['mymod-page_title'] = t("Page title because ignores defaults.");
    }
  }
  return $tokens;
}

/**
 * Implementation of hook_token_values().
 */
function mymod_token_values($type, $object = NULL) {
  $values = array();

  if ($type == 'taxonomy') {
    if (module_exists('page_title')) {
      $term_title = page_title_load_title($object->tid, 'term');
      $values['mymod-page_title'] = !empty($term_title) ? $term_title : $object->name;
    }
  }

  return $values;
}