Customize Title Tag for Search Results Customize Title Tag for Search Results
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Customize Title Tag for Search Results

Started by Walkinman, January 30, 2013, 11:25:04 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Walkinman

Hey Folks,

You can see from this thread
http://forum.coppermine-gallery.net/index.php/topic,75933.msg366396.html

I've made some adjustments to tweak the Title Tags (and meta tag "description") for the cpg section of the site. What I would like to do now is slightly tweak the Title Tag for my "search results" page: Currently, a search for "mount blackburn" would yield a Title tag

QuoteImage Search Results ="mount blackburn"

I would like to add "Stock Photos", or "| Stock Photos" after that, as

QuoteImage Search Results = "mount blackburn" Stock Photos

But I don't know how. Any assistance is appreciated.

Thanks so much.

Cheers

Carl

Αndré

You're doing the mod the wrong round. The default page title for search results is:
QuoteImage search results - "mount blackburn" - Stock Photos
("Stock Photos" is the gallery name).

So what you're actually looking for is how to remove the gallery name from the page title for other pages. If this is correct, please undo your mods to the page title and we'll proceed here.

Walkinman

Hey André

I think I've simply described things a little awkwardly.

Right now, with the mod linked to above, everything works fine. I can write custom title tags, and they work great. And I removed the Gallery Name {Stock Photos} via your help here
http://forum.coppermine-gallery.net/index.php/topic,75933.msg366387.html#msg366387

and my follow up reply to that post. So that's correct; currently the gallery name is not showing any of the pages.

But ..... I would actually like to have the gallery name appear on the search results' Title Tag - but only on the search results. And I do [b[NOT[/b] want it to appear on all the albums/category pages (which is it currently does not).

To be honest, it doesn't even need to be the Gallery Name displayed in the search results; just the opportunity to make use of some more keyword text there, and particularly put the word "photos" in the tag .. preferably after the keyword phrase.

Are you saying the better way to to this is undo the last code I did in that thread, so everything reverts to a default, then find an alternate way to remove the Gallery Name from the Album and Category Title Tags? If so, that's fine; just let me know the best way to proceed from here.

Thanks so much for your help.

Cheers

Αndré

The following mod expects an unmodified gallery (at least no changes to the pageheader functions).

Copy the function theme_page_title from themes/sample/theme.php to your theme's theme.php file. Then, find
    $return = strip_tags(bb_decode($section)) . ' - ' . $CONFIG['gallery_name'];
and replace with
    $superCage = Inspekt::makeSuperCage();
    if ($superCage->get->keyExists('album') && $superCage->get->getAlpha('album') == 'search') {
        $return = strip_tags(bb_decode($section)) . ' - ' . $CONFIG['gallery_name'];
    } else {
        $return = strip_tags(bb_decode($section));
    }



Feel free to replace $CONFIG['gallery_name'] with any keywords you'd like to use.

Walkinman

Hey André

Thanks - this is the code I have in my file now

/******************************************************************************
** Section <<<theme_page_title>>> - START
******************************************************************************/
// Creates the title tag for each page
// For the sake of search engine friendliness, the dynamic part $section should come first
function theme_page_title($section)
{
    global $CONFIG;
    $superCage = Inspekt::makeSuperCage();
    if (strpos($superCage->server->getRaw('PHP_SELF'), 'index.php') !== FALSE && ! $superCage->get->getInt('cat'))
    {
        $return = strip_tags(bb_decode($section)) . ' | ' . $CONFIG['gallery_name'] . ($CONFIG['gallery_description'] ? " | " . $CONFIG['gallery_description'] : '');
    }
else if ($superCage->get->keyExists('album') && $superCage->get->getAlpha('album') == 'search') {
        $return = strip_tags(bb_decode($section)) . ' ' . $CONFIG['gallery_name'];
}
    else
    {
        $return = strip_tags(bb_decode($section));
    }
    return $return;
}
/******************************************************************************
** Section <<<theme_page_title>>> - END
******************************************************************************/


It works!

Thank you so much,

Cheers

Carl