I've attached, for discussion, a patch to get page_titles to apply the taxonomy settings to ubercart catalog pages.

We are happily using page_title to customise the titles of other types of pages, but it doesn't work for ubercart category pages, which are basically fancy taxonomy term pages.

So my questions are:

  • Is this the correct way to go about getting page_titles to work?
  • If it is, would it be better to have a separate setting for taxonomy pages and for ubercart category pages?
  • If it is isn't, what would be the correct way about getting this to work correctly? Are there any plans to make some sort of hook system to extend the page_title module?

I believe there would be some demand for this feature from ubercart users.

Comments

dougp’s picture

Correct patch

nicholasthompson’s picture

Version: 6.x-2.2 » 6.x-2.x-dev
Status: Active » Closed (won't fix)

Marking this as "wont fix". I appreciate the patch as it has brought to my attention how un-scalable the module is.

I've just committed a new feature to the dev branches of Page Title. There are two hooks..

hook_page_title_alter(&$title)
hook_page_title_pattern_alter(&$page_title_pattern, &$tokens = NULL)

With these two functions, you can get uc_catalog to hook into Page Title and provide it's own pattern and title for its own pages.

Note: The implemtations of the pattern alter hook requires tokens to default to NULL as the frontpage does not have any tokens.
Another Note: This is a brand new hook and is in dev. I think it's pretty much ready to go - but I wouldn't "bank" on it just yet... :-)

dougp’s picture

Hey, that's great! I'll keep manually patching the stable version for the moment, but I'm looking forward to doing it properly with those hooks!

Duplika’s picture

It would be great to be able to manage Page Titles from the catalog pages Ubercart creates, subscribing.

quip’s picture

this patch is working, but in this case catalog titles generating automatically with configured template.

how to define every title manually?

thanks.

jasonabc’s picture

subscribing

kazah’s picture

subscribe

u210ks’s picture

subscribe

ucf713’s picture

Thanks for the patch.

I placed this inside my template.php file and added the check for page_title and the setting of the head_title. Replace THEME with your theme name.

function THEME_preprocess_page(&$vars) 
{
    if (arg(0) == 'catalog' && is_numeric(arg(1)) && module_exists('uc_catalog') && module_exists('page_title')) 
    {
        $term = taxonomy_get_term(arg(1));

        if (variable_get('page_title_vocab_'. $term->vid .'_showfield', 0) && ($term_title = page_title_load_title($term->tid, 'term')))
        {
            $title = check_plain(strip_tags($term_title));
            $vars['head_title'] = $title;
        }
    }
}
jasonabc’s picture

@ucf713 - thanks very much. That code works great.