Advanced search  

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

Pages: [1]   Go Down

Author Topic: Customize Title Tag for Search Results  (Read 3351 times)

0 Members and 1 Guest are viewing this topic.

Walkinman

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 380
    • Skolai Images - Nature, Travel and Adventure stock photos
Customize Title Tag for Search Results
« on: January 30, 2013, 11:25:04 am »

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

Quote
Image Search Results ="mount blackburn"

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

Quote
Image Search Results = "mount blackburn" Stock Photos

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

Thanks so much.

Cheers

Carl
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Customize Title Tag for Search Results
« Reply #1 on: January 30, 2013, 11:35:25 am »

You're doing the mod the wrong round. The default page title for search results is:
Quote
Image 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.
Logged

Walkinman

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 380
    • Skolai Images - Nature, Travel and Adventure stock photos
Re: Customize Title Tag for Search Results
« Reply #2 on: January 30, 2013, 09:43:22 pm »

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
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Customize Title Tag for Search Results
« Reply #3 on: January 31, 2013, 11:48:46 am »

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
Code: [Select]
    $return = strip_tags(bb_decode($section)) . ' - ' . $CONFIG['gallery_name'];and replace with
Code: [Select]
    $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.
Logged

Walkinman

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 380
    • Skolai Images - Nature, Travel and Adventure stock photos
Re: Customize Title Tag for Search Results
« Reply #4 on: January 31, 2013, 08:58:40 pm »

Hey André

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

Code: [Select]
/******************************************************************************
** 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
Logged
Pages: [1]   Go Up
 

Page created in 0.028 seconds with 19 queries.