Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Creating meta tag description for Category Pages  (Read 2886 times)

0 Members and 1 Guest are viewing this topic.

Walkinman

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 376
    • Skolai Images - Nature, Travel and Adventure stock photos
Creating meta tag description for Category Pages
« on: January 04, 2014, 01:35:33 am »

hey Folks,

I posted another thread here

http://forum.coppermine-gallery.net/index.php/topic,76964.0.html

to display the description for a category page. Now I would like to also add a meta  tag "description" for the pages. I have a code setup on my site that allows me to write one when I create a category (separate from the description that will appear on the page) but I can't get it to actually show in the source code.

How do I make the meta tag description tag show up (not on the page, but in the header)? I thought I had it showing up before, but I don't see it now for Category pages. I tried adding this code, which is what generates the meta tag for albums

Code: [Select]
// trying to add a meta tag description

 $meta_description = $CURRENT_ALBUM_DATA['meta_description'] ? $CURRENT_ALBUM_DATA['meta_description'] : $CURRENT_ALBUM_DATA['description'];
if ($meta_description)
{
    $meta_keywords .= '<meta name="description" content="' . htmlspecialchars($meta_description) . '" />' . $LINEBREAK;
}

and also changing $CURRENT_ALBUM_DATA to $CURRENT_CAT_DATA but that didn't work either. That above is the code I have to produce the meta tag for album thumbnails, and I thought maybe I could slide it into the display_cat_list section, but it doesn't work.

Thanks,

Cheers

Carl
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765
Re: Creating meta tag description for Category Pages
« Reply #1 on: January 13, 2014, 03:15:34 pm »

Unfortunately our recent conversion is lost due to the site outage. If I remember correctly foulu created that mod for you, but you currently have no clue where your meta description data is stored (probably foulu added an additional column to the categories table).

If we know how to get that data from the database, we can add it as additional parameter to the pageheader function in index.php.
Logged

Walkinman

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 376
    • Skolai Images - Nature, Travel and Adventure stock photos
Re: Creating meta tag description for Category Pages
« Reply #2 on: January 21, 2014, 10:21:03 am »

Hey André

I found the post I made where I listed the mods Foulu created here
http://forum.coppermine-gallery.net/index.php/topic,75933.msg366382.html#msg366382

and my follow up post below that as well. Does that tell you what you're looking for?

Cheers

Carl
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765
Re: Creating meta tag description for Category Pages
« Reply #3 on: January 21, 2014, 10:40:38 am »

This looks promising:
Code: [Select]
SELECT page_title, meta_description FROM {$CONFIG['TABLE_CATEGORIES']}
The code in your other file contains:
Code: [Select]
$meta_description = $CURRENT_ALBUM_DATA['meta_description'] ? $CURRENT_ALBUM_DATA['meta_description'] : $CURRENT_ALBUM_DATA['description'];which means, that the meta_description is used if available, otherwise the "regular" description. Do you want to apply the same approach for your categories or do you want to omit the meta tag if there's no meta_description for the current category?
Logged

Walkinman

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 376
    • Skolai Images - Nature, Travel and Adventure stock photos
Re: Creating meta tag description for Category Pages
« Reply #4 on: January 23, 2014, 11:52:06 am »

Hi André

It really doesn't matter too much for my purposes; I'll have a custom meta_description for each category, so I don't really need the option to use one over the other. Just the custom one I write on the edit category page. Whichever method is easier works fine.

Thanks so much

Cheers

Carl
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765
Re: Creating meta tag description for Category Pages
« Reply #5 on: January 23, 2014, 03:49:47 pm »

Open index.php, find
Code: [Select]
pageheader($BREADCRUMB_TEXT ? $BREADCRUMB_TEXT : $lang_index_php['welcome']);and replace with
Code: [Select]
    $meta_description = mysql_result(cpg_db_query("SELECT meta_description FROM {$CONFIG['TABLE_CATEGORIES']} where cid = $cat LIMIT 1"), 0);
    $meta_description = $meta_description ? '<meta name="description" content="' . htmlspecialchars($meta_description) . '" />': '';
    pageheader($BREADCRUMB_TEXT ? $BREADCRUMB_TEXT : $lang_index_php['welcome'], $meta_description);
Logged

Walkinman

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 376
    • Skolai Images - Nature, Travel and Adventure stock photos
Re: Creating meta tag description for Category Pages
« Reply #6 on: January 24, 2014, 10:14:04 am »

Hey André

Sorry to be such a pain; are you sure that's in index.php? I can't find it in either that or theme.php

Cheers

Carl
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765
Re: Creating meta tag description for Category Pages
« Reply #7 on: January 24, 2014, 12:40:31 pm »

It's definitely in index.php. Please search for "pageheader" (there should be just one result), maybe you already modified the parameters.
Logged

Walkinman

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 376
    • Skolai Images - Nature, Travel and Adventure stock photos
Re: Creating meta tag description for Category Pages
« Reply #8 on: January 25, 2014, 05:05:12 am »

Hey André

Weird - for some reason now it shows up. Thanks for your patience.

That fixed it. Marking the thread solved, thanks so much.

Cheers

Carl
Logged
Pages: [1]   Go Up
 

Page created in 0.026 seconds with 19 queries.