Creating meta tag description for Category Pages Creating meta tag description for Category Pages
 

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

Creating meta tag description for Category Pages

Started by Walkinman, January 04, 2014, 01:35:33 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Walkinman

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

Αndré

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.

Walkinman

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

Αndré

This looks promising:
SELECT page_title, meta_description FROM {$CONFIG['TABLE_CATEGORIES']}

The code in your other file contains:
$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?

Walkinman

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

Αndré

Open index.php, find
pageheader($BREADCRUMB_TEXT ? $BREADCRUMB_TEXT : $lang_index_php['welcome']);
and replace with
    $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);

Walkinman

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

Αndré

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

Walkinman

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