forum.coppermine-gallery.net

No Support => Modifications/Add-Ons/Hacks => Mods: Searching => Topic started by: wipqozn1 on May 08, 2007, 06:00:20 pm

Title: Dynamic meta descriptions
Post by: wipqozn1 on May 08, 2007, 06:00:20 pm
Is there a way to create dynamic meta description for each (or most of them) page in Coppermine? For example:

<second part of tittle><constant text>




[Edit GauGau] The first few postings on this thread are the questions and unrelated discussion. If you're looking for the actual mod to accomplish dynamic meta descriptions, scroll down a little to the contribution by Ludo. [/edit]

Title: Re: Dynamic meta descriptions
Post by: Joachim Müller on May 09, 2007, 07:25:29 am
Depends on where you want to put them. For the intermediate image display, edit displayimage.php, find <meta and edit the stuuf around it as you see fit. Basically, whenever the function pageheader is being called, you can add (as second parameter) any type of meta information. For details, post details.
Title: Re: Dynamic meta descriptions
Post by: wipqozn1 on May 09, 2007, 01:32:17 pm
Well, I was rather thinking about doing this in template files, 'cause I'd like to have dynamic descriptions for every page in gallery.

In displayimage.php there is a line:

Code: [Select]
    if ($CURRENT_PIC_DATA['keywords']) { $meta_keywords = "<meta name=\"keywords\" content=\"".$CURRENT_PIC_DATA['keywords']."\"/>"; }
It's only about meta keywords. Could You give me an example of line which will give me a possibility to display constant text in meta description and a name of recent page? Like this:

$tit = <name of recent page> [e.g. Top Commented]
$cdesc = <constant defind description>

And display it like this:

 <meta name="Description" content="{tit}{desc}{tit}" />
Title: Re: Dynamic meta descriptions
Post by: Joachim Müller on May 09, 2007, 07:19:44 pm
I have no idea what you're talking about. Is your meta tag's content suppossed to be dynamic or static? If it is suppossed to be dynamic, where should the content come from. If it's static, why don't you just edit themes/yourtheme/template.html as you see fit?
Title: Re: Dynamic meta descriptions
Post by: wipqozn1 on May 09, 2007, 07:39:17 pm
I want my meta description for every pages consists of TWO elements: first would be dynamic, second static.

Dynamic would be a name of current page, static would be a text defined by me (static element is supposed to be the same for all pages)

Schema for all pages:

<meta name="Description" content="<title of page><static text defined by me" />

It is a mix of dynamic and static elements, so can't be done via template.html.

All I want to know is how could I put title of page in meta description and where define my static text for display next to dynamic element.
Title: Re: Dynamic meta descriptions
Post by: Joachim Müller on May 10, 2007, 07:55:20 am
As suggested above, this depends on what pages are suppossed to contain the meta tag and where you want to pull the dynamic data from. The title is being composed from the Gallery name that you have set up in Coppermine's config and whatever the coppermine page that you're on sends as content when calling the function pageheader.
Bottom line: edit whatever page you want to see changed and take a look at what is being sent to the pageheader function.
I told you above to post details. Any particular reason for not doing as suggested and playing hide and seek with me?
Title: Re: Dynamic meta descriptions
Post by: wipqozn1 on May 10, 2007, 10:20:11 am
To be sincere, I don't exactly know what else details would You like to know.

I'll give You another example. Please look here: http://gryz.pl/faq.php When You take a look at the page source, You can see this line:

Code: [Select]
<title>Gryz.pl - Gry online. Nie do przegryzienia. - Często zadawane pytania</title>
This: "Gryz.pl - Gry online. Nie do przegryzienia." is a desc of gallery defined in admin panel, we don't care about it now.

This: "Często zadawane pytania" is a TITLE of this particular page, and I want to have this TITLE in my meta description tag. And I also want put a static text "on our gaming site" after this TITLE. So I would like compose it like this:

<meta name="Description" content="Często zadawane pytania on our gaming site" />

If name of a page would be "searching", I would like to have this "searching" in my meta desc + static text showed above so it'd be like this:

<meta name="Description" content="Searching on our gaming site" />

another example:

<meta name="Description" content="Last commented on our gaming site" />

etc.

I can't tell You on which pages I want to display this meta... or no, I can: I want diplay this on every page within my gallery. It can be done for every pages at once I guess. Within which file $meta is defined?
Title: Re: Dynamic meta descriptions
Post by: Joachim Müller on May 10, 2007, 10:29:51 am
To change the meta tag of the FAQ page, edit faq.php, find
Code: [Select]
pageheader($lang_faq_php['faq']);and replace with
Code: [Select]
$meta_description = '<meta name="Description" content="Często zadawane pytania on our gaming site" />';
pageheader($lang_faq_php['faq'], $meta_description );
Simple as that.
Title: Re: Dynamic meta descriptions
Post by: wipqozn1 on May 10, 2007, 11:45:51 am
Okay, so You know what I'd like to achieve :-)

Since only a couple of pages have their own ".php file" could You also tell me how can I get a title of page? Now, I would like to implement this for all pages, e.g. thumbnails.php:

Code: [Select]
pageheader(isset($CURRENT_ALBUM_DATA) ? $CURRENT_ALBUM_DATA['title'] : $lang_meta_album_names[$album]);
Is this okay?

Code: [Select]
$meta_description = '<meta name="Description" content="'.$CURRENT_ALBUM_DATA['title'].' on our gaming site" />';

pageheader(isset($CURRENT_ALBUM_DATA) ? $CURRENT_ALBUM_DATA['title'] : $lang_meta_album_names[$album], $meta_description);

Title: Re: Dynamic meta descriptions
Post by: Joachim Müller on May 10, 2007, 03:57:34 pm
Why don't you just try and give us feedback?
Title: Re: Dynamic meta descriptions
Post by: Walkinman on May 15, 2007, 03:29:51 pm
Hey Folks,

I'd really apprecaite it if someone could offer some ideas/help onhow to set this up.

Thank you.

Cheers

Carl
Title: Re: Dynamic meta descriptions
Post by: wipqozn1 on May 16, 2007, 12:00:40 pm
It works:

Code: [Select]
$meta_description = '<meta name="Description" content="'.$CURRENT_ALBUM_DATA['title'].' on our gaming site" />';

pageheader(isset($CURRENT_ALBUM_DATA) ? $CURRENT_ALBUM_DATA['title'] : $lang_meta_album_names[$album], $meta_description);

And similar one for diplayimage.php:

Code: [Select]
        $meta_keywords .= $meta_nav;
$meta_description = '<meta name="Description" content="Game '.$picture_title.' on our gaming site.Play in  '.$picture_title.' or another game in category '.$CURRENT_ALBUM_DATA['title'].'. Another static text goes here." />';
    pageheader($album_name . '/' . $picture_title, $meta_description, false);

Last example doesn't show meta keywords (original lines do) since it's ignored by almost all search engines anyway.
Title: Re: Dynamic meta descriptions
Post by: Brane29 on June 06, 2007, 10:07:38 am
Hi!
Ok, this is helpfull. But my question is: will this work when bridged with joomla!? Meta tags are loaded from joomla header and I would like to have image title or image description in meta tag.

Thanx for your time and help!
Title: Re: Dynamic meta descriptions
Post by: Joachim Müller on June 06, 2007, 12:59:47 pm
Why don't you just try and give us feedback?
Can't see why above mentioned modifications should not work when Coppermine is being bridged with Joomla (or any other app). Bridging doesn't deal with visual integration anyway. However, we have no idea about Joomla and how it works. As suggested: find it out and report back. If it doesn't work as expected, undo your changes and that's it. I can't see the point in asking "will this work with XXX?".
Title: Re: Dynamic meta descriptions
Post by: Brane29 on June 06, 2007, 01:17:14 pm
Ok, my english is not so good so I did asked question wrong. I have allready bridged to joomla in wrapped mode so my coppermine gallery is wrapped in joomla template. Meta tags are loaded from joomla header. That's why I ask about meta tags from coppermine.

I'm sorry for missunderstund...please forgive me.

P.S. Link to my site is: http://www.fotoimota.net (http://www.fotoimota.net)

Thanx
Title: Re: Dynamic meta descriptions
Post by: Joachim Müller on June 06, 2007, 01:37:36 pm
we have no idea about Joomla and how it works.
Title: Re: Dynamic meta descriptions
Post by: Brane29 on June 08, 2007, 09:29:03 am


"WE" represent you as a dev team and I really did understand that you do not know things about joomla.
I also understand that you hav 32000 post and that you are tired answering questions like mine. But please understand that someone else could give me answer...if someone else know things about joomla and Mehdi's bridge for coppermine. So, if you don't know the answer, don't answer and let other answer if they want. SMF Bridge for joomla solved problem with meta tags so coppermine bridge dev team, or someome else, could read this and help.

Thanke you!
Title: Re: Dynamic meta descriptions
Post by: Joachim Müller on June 08, 2007, 11:00:26 am
Yes: someone who is familiar with both Coppermine and Joomla possibly could answer your question. However, you hijacked a thread that discusses meta tags used in a standalone coppermine environment. Your question would have belonged into a separate thread or (even better) into a support board that deals with Joomla. We allow questions that deal with what we know: Coppermine. If people post questions that do not deal with Coppermine, we tell them so. Our board is dedicated to Coppermine only. Just because somebody might come along who by accident is skilled both in Coppermine as well as Joomla doesn't make your question a valid one on the Coppermine support board. It's our decision what type of questions we want to see discussed. It's true that an answer that simply says "I don't know" doesn't make sense - generally speaking. So I should have said: "I don't know and your question is off topic and beyond the scope of this support board. Ask it somewhere else". We have strict rules on what kind of questions we allow on this forum to avoid it from being cluttered with irrelevant content. Somebody could as well post the question "how do I fix the engine of a Volkswagen Beetle?". Of course we could allow that sort of question, as there could be somebody who knows how to fix cars who accidentally visits the Coppermine board. However, we don't allow it. Your question is not as much off-topic as a question related to car repair would be. However, it's our choice what level of off-topic-ness we allow. That's why I haven't deleted your posting in the first place, but replied to it saying that you're suppossed to find help somewhere else.
I'm actually really tired having to explain our forum policies in details again and again. After all, it's our decision what kind of postings/questions we allow.

Joachim
Title: Re: Dynamic meta descriptions
Post by: Brane29 on June 09, 2007, 09:34:27 pm
Ok, I do apologize fot off topic. I didn't know it is off topic after all. My english language is not so good so I can not be shure if I'm wrong in something or not.
My language is croatian and I do know about off topic so please have a little maners on strangers. I'm not bad and do not want troubles. I need help and would like to help others. Delete this if you want. I don't care any more!
Title: Re: Dynamic meta descriptions
Post by: Ludo on October 08, 2007, 04:19:15 pm
DYNAMIC META DESCRIPTION TAGS MOD
This mod adds dynamic meta description tags to almost every page (categories, albums and images).
Meta description tag is filled respectively with category description, album description and image caption text, or, if it's not set, with a default site description set in config.inc.php.
HTML/BBCode tags stripped before building meta tag, if necessary.
Page number added both to meta description and page title in thumbnails page to avoid duplications when album spreads over multiple pages.
Thanks to GauGau for the hints above.

Files to edit:
include/config.inc.php
displayimage.php
index.php
thumbnails.php
lang/your_lang.php



OPEN
include/config.inc.php

FIND (at the end of file):
Code: [Select]
?>
BEFORE, ADD
Code: [Select]
// DEFAULT META DESCRIPTION TEXT
$CONFIG['meta_description'] = 'Your site default meta description text';


OPEN
displayimage.php

FIND (line 316)
Code: [Select]
if ($CURRENT_PIC_DATA['keywords']) { $meta_keywords = "<meta name=\"keywords\" content=\"".$CURRENT_PIC_DATA['keywords']."\"/>"; }
AFTER, ADD
Code: [Select]
    $meta_description = empty($CURRENT_PIC_DATA['caption']) ? $CONFIG['meta_description'] : strip_tags(bb_decode($CURRENT_PIC_DATA['caption']));
    $desc_len = strlen($meta_description);
    if (!is_numeric($album)) $desc_len += strlen($album_name)+3;
    if ($desc_len > 200) {
        $offset = 170;
        if (!is_numeric($album)) $offset -= strlen($album_name)+3;    
        $meta_description = substr($meta_description, 0, strpos($meta_description, " ", $offset))."...";                    
    }
    if (!is_numeric($album)) $meta_description .= " - " . $album_name;            
    $meta_description = "\n<meta name=\"description\" content=\"$meta_description\" />\n";
    $meta_keywords .= $meta_description;


OPEN
index.php

FIND (line 756)
Code: [Select]
if (isset($cat)) {
BEFORE, ADD
Code: [Select]
$meta_description = $CONFIG['meta_description'];
FIND (line 757)
Code: [Select]
get_meta_album_set($cat,$META_ALBUM_SET);
AFTER, ADD
Code: [Select]
$result = cpg_db_query("SELECT description FROM {$CONFIG['TABLE_CATEGORIES']} WHERE cid = '$cat'");
if (mysql_num_rows($result) > 0) list($cat_desc) = mysql_fetch_array($result);
if (!empty($cat_desc)) {
   $meta_description = strip_tags(bb_decode($cat_desc));
} else if ($cat >= FIRST_USER_CAT) {
   $user_name = get_username($cat - FIRST_USER_CAT);
   if (!$user_name) $user_name = 'Mr. X';
   $meta_description = sprintf($lang_list_categories['xx_s_gallery'], $user_name);
}
mysql_free_result($result);

FIND (line 764)
Code: [Select]
   pageheader($BREADCRUMB_TEXT ? $BREADCRUMB_TEXT : $lang_index_php['welcome']);
REPLACE WITH
Code: [Select]
    $desc_len = strlen($meta_description);
    if (isset($_GET['cat']) && $PAGE > 1) $desc_len += strlen($lang_index_php['page'] . " $PAGE")+3;
    if ($desc_len > 200) {
        $offset = 170;
        if (isset($_GET['cat']) && $PAGE > 1) $offset -= strlen($lang_index_php['page'] . " $PAGE")+3;    
        $meta_description = substr($meta_description, 0, strpos($meta_description, " ", $offset))."...";                            
    }
    if (isset($_GET['cat']) && $PAGE > 1) $meta_description .= " - " . $lang_index_php['page'] . " $PAGE";    
    $meta_description = "<meta name=\"description\" content=\"$meta_description\" />\n";
    $page_title = ($BREADCRUMB_TEXT) ? $BREADCRUMB_TEXT : $lang_index_php['welcome'];
    if (isset($_GET['cat']) && $PAGE > 1) $page_title .= " - " . $lang_index_php['page'] . " $PAGE";      
    pageheader($page_title, $meta_description);


OPEN
thumbnails.php

FIND (line 163)
Code: [Select]
pageheader(isset($CURRENT_ALBUM_DATA) ? $CURRENT_ALBUM_DATA['title'] : $lang_meta_album_names[$album]);
REPLACE WITH
Code: [Select]
$page_title = (isset($CURRENT_ALBUM_DATA) ? $CURRENT_ALBUM_DATA['title'] : $lang_meta_album_names[$album]);
$meta_description = isset($CURRENT_ALBUM_DATA['description']) ? strip_tags(bb_decode($CURRENT_ALBUM_DATA['description'])) : $CONFIG['meta_description'];
$desc_len = strlen($meta_description);
if (isset($CURRENT_ALBUM_DATA)) $desc_len += strlen($lang_meta_album_names[$album])+3;
if ($page > 1) $desc_len += strlen($lang_thumbnails_php['page'] . " $page")+3;
if ($desc_len > 200) {
    $offset = 170;
    if (isset($CURRENT_ALBUM_DATA)) $offset -= strlen($lang_meta_album_names[$album])+3;
    if ($page > 1) $offset -= strlen($lang_thumbnails_php['page'] . " $page")+3;    
    $meta_description = substr($meta_description, 0, strpos($meta_description, " ", $offset))."...";                    
}
if (!isset($CURRENT_ALBUM_DATA)) $meta_description .= " - " . $lang_meta_album_names[$album];
if ($page > 1) {
    $page_title .= " - " . $lang_thumbnails_php['page'] . " $page";
    $meta_description .= " - " . $lang_thumbnails_php['page'] . " $page";
}
$meta_description = "<meta name=\"description\" content=\"$meta_description\" />\n";
pageheader($page_title, $meta_description);


OPEN
lang/your_lang.php

FIND (line 1282)
Code: [Select]
);

$lang_album_admin_menu = array(

BEFORE, ADD (translate "Page" in your_lang!)
Code: [Select]
 'page' => 'Page',  
FIND (line 1714)
Code: [Select]
// ------------------------------------------------------------------------- //
// File thumbnails.php
// ------------------------------------------------------------------------- //


AFTER, ADD (translate "Page" in your_lang!)
Code: [Select]
if (defined('THUMBNAILS_PHP')) $lang_thumbnails_php = array(
  'page' => 'Page'
);

FIND AND DELETE (line below)
Code: [Select]
// Void

SAVE AND CLOSE ALL FILES
Title: Re: Dynamic meta descriptions
Post by: Alfinators on January 26, 2008, 01:43:39 am
THANKS very useful
Title: Re: Dynamic meta descriptions
Post by: Snaver on November 09, 2008, 01:26:30 am
Really excellent work apart from i had to remove these lines of code for it to work apart from that tho its great, oh and added my own custom description thing that you left out..

Code: [Select]
if (mysql_num_rows($result) == 0)
   cpg_die(CRITICAL_ERROR, $lang_errors['non_exist_cat'], __FILE__, __LINE__);
list($cat_desc) = mysql_fetch_array($result);
Title: Re: Dynamic meta descriptions
Post by: Ludo on November 09, 2008, 02:56:52 pm
Really excellent work
Thanks a lot.

Quote
apart from i had to remove these lines of code for it to work apart

Code: [Select]
if (mysql_num_rows($result) == 0)
   cpg_die(CRITICAL_ERROR, $lang_errors['non_exist_cat'], __FILE__, __LINE__);
list($cat_desc) = mysql_fetch_array($result);
These lines extract categories description: what point in removing them?  ???

Quote
added my own custom description thing that you left out..
Are you talking about the default description text in config.inc.php? :P
Title: Re: Dynamic meta descriptions
Post by: RichardG on November 19, 2008, 03:33:56 am
I used the displayimage.php mod to generate meta tag descriptions and keywords and have ended up with two of each as my Coppermine is integrated with Joomla. I have only used displayimage as I have pumped all my displayimages into google with a little script which reads the Coppermine database and produces an XML file pointing to all the photos in the database. If anyone is interested I will post it on this forum. It generated 700+ entries and google accepted them all.

I am not sure if search engines will look at two sets of meta tags - does anyone know.

You can see the dual meta tags when looking at the gallery in www.ukbigpeople.co.uk.

Regards

Richard
Title: Re: Dynamic meta descriptions
Post by: Ludo on November 19, 2008, 11:14:45 am
I have pumped all my displayimages into google with a little script which reads the Coppermine database and produces an XML file pointing to all the photos in the database. If anyone is interested I will post it on this forum. It generated 700+ entries and google accepted them all.
Sounds like a Google sitemap (http://forum.coppermine-gallery.net/index.php/topic,18749.0.html)...  ::)

I am not sure if search engines will look at two sets of meta tags - does anyone know.
If you take a look at Google search results, it seems to take in account only the first one, as expected. Why duplicate tags?
Title: Re: Dynamic meta descriptions
Post by: RichardG on November 19, 2008, 08:12:27 pm
Sorry I should have mentioned it was a Google sitemap.

The duplication must be happening because the bridge does not take account of Coppermine and Joomla being together. Not sure where to start looking to add them together. May investigate further and add it here if I find a solution.

Title: Re: Dynamic meta descriptions
Post by: mywedding on November 20, 2008, 10:37:04 pm
ludo that is great job, i kissed u,  :-*

thx
Title: Re: Dynamic meta descriptions
Post by: Ludo on November 21, 2008, 08:56:25 am
 :o :-* ;)
Title: Re: Dynamic meta descriptions
Post by: Jmaj on November 27, 2008, 04:34:22 pm
Thanks a lot Ludo, this is what I needed!

I have one question, do you know how I can get it to work for the displayimage page?

I didn't see the <mete description etc in the page source
Title: Re: Dynamic meta descriptions
Post by: Ludo on November 28, 2008, 08:35:51 am
As you can see by this example (http://vanrokken.altervista.org/displayimage.php?album=random&cat=0&pos=-493) from my gallery, dynamic meta descriptions do appear in image pages source :P ;)
Please make sure you modded properly displayimage.php file, and post a link to an image page in your gallery...
Title: Re: Dynamic meta descriptions
Post by: whats_up_skip on December 08, 2008, 05:05:45 am
Thanks Ludo this is fantastic.

I was just about to post a request about this sort of thing as Google Webmaster Tools is reporting many problems with the Coppermine without this sort of modification. It says there are duplicate titles and duplicate meta descriptions, which tends to imply that it thinks that it may be duplicate content on the site. Either way it is not giving the Coppermine picture gallery content a good ranking in the SEO results.

I would like to suggest a few additional improvement to this mod:

thumbnails.php
If there are multiple pages, then they will end up with the identical titles and descriptions tags. It would be great if there are multiple pages that the page number was added to the title and description tag.

It would also be great if the heading on the page (H1 tag) was the album name and the subtitle (H3) was the caption. This would greatly improve the page in Google's eyes as the H1 and H3 tags would no longer be the same on all pages (This is really bad from a search engine optimisation point of view).

displayimage.php
Again it would also be great if the heading on the page (H1 tag) was the album name and the subtitle (H3) was the caption. This would greatly improve the page in Google's eyes as the H1 and H3 tags would no longer be the same on all pages (This is really bad from a search engine optimisation point of view).
Title: Re: Dynamic meta descriptions
Post by: Ludo on December 11, 2008, 03:15:21 pm
Thanks Ludo this is fantastic.
:-[ :-*

Quote
If there are multiple pages, then they will end up with the identical titles and descriptions tags. It would be great if there are multiple pages that the page number was added to the title and description tag.
That's a good idea, I will work on accomplishing it  ;)

Quote
It would also be great if the heading on the page (H1 tag) was the album name and the subtitle (H3) was the caption. This would greatly improve the page in Google's eyes as the H1 and H3 tags would no longer be the same on all pages (This is really bad from a search engine optimisation point of view).

displayimage.php
Again it would also be great if the heading on the page (H1 tag) was the album name and the subtitle (H3) was the caption. This would greatly improve the page in Google's eyes as the H1 and H3 tags would no longer be the same on all pages (This is really bad from a search engine optimisation point of view).
These suggestions aren't strictly related to this mod indeed...
Title: Re: Dynamic meta descriptions
Post by: Ludo on December 11, 2008, 03:48:06 pm
That's a good idea, I will work on accomplishing it  ;)
Done!  ;D ;)
Look at source code of this page (http://vanrokken.altervista.org/thumbnails.php?album=86&page=3) for a demo.
Title: Re: Dynamic meta descriptions
Post by: whats_up_skip on January 07, 2009, 06:45:19 am
Done!  ;D ;)
Look at source code of this page (http://vanrokken.altervista.org/thumbnails.php?album=86&page=3) for a demo.

I hadn't realised you had updated the code for thumbnails.php. Thanks for that.

This solves the issue of duplicate meta "description", however the "Title" is still duplicated. This could be fixed if current "Title" had "page n" added for all pages after the first page.

There is also the problem of duplicate meta "description" for "Last additions", "Most Viewed" and "Top Rated". This could be resolved in a similar way to the thumbnails.php page number by adding "Last additions" at the end of the "description". The "Title" tag does not need to be changed as this is already different to the standard displayimage.

I suspect these are the duplicate issues that others had mentioned above and that they are not related to bridged application.

Thanks again for all your help with this mod, it is really improving our galleries in the eyes of Google.
Title: Re: Dynamic meta descriptions
Post by: Ludo on January 07, 2009, 10:29:15 am
"Title" is still duplicated. This could be fixed if current "Title" had "page n" added for all pages after the first page.

There is also the problem of duplicate meta "description" for "Last additions", "Most Viewed" and "Top Rated". This could be resolved in a similar way to the thumbnails.php page number by adding "Last additions" at the end of the "description".
Done (mod code updated :P )!  8)
Demos:
Last additions (http://vanrokken.altervista.org/thumbnails.php?album=lastup&cat=0&page=3)
Most viewed (http://vanrokken.altervista.org/thumbnails.php?album=topn&cat=0&page=2)
Standard album (http://vanrokken.altervista.org/thumbnails.php?album=87&page=2)
Title: Re: Dynamic meta descriptions
Post by: whats_up_skip on January 07, 2009, 10:33:23 pm
You fixed something I had not thought of, but I don't think I explained clearly the other issue.

The "description" tag in the displayimage version of the "Last additions", "Most Viewed" and "Top Rated".

For example:
http://vanrokken.altervista.org/displayimage.php?album=lastup&cat=0&pos=32

<meta name="description" content="A sud del Bue, la vetta erbosa del Maggiorasca, anch&#39;essa deturpata da ripetitori." />

Will be a duplicate of the normal version of the displayimage of this file. It needs to have something like "Last additions" added to the end of the description.

The same would also be the case for "Most Viewed" and "Top Rated".

Thanks again for you help with this. I have tried to make these changes myself, but I just don't have the php skills required.
Title: Re: Dynamic meta descriptions
Post by: Ludo on January 08, 2009, 12:06:19 am
The "description" tag in the displayimage version of the "Last additions", "Most Viewed" and "Top Rated".

For example:
http://vanrokken.altervista.org/displayimage.php?album=lastup&cat=0&pos=32
Here it is (mod code updated)!
Title: Re: Dynamic meta descriptions
Post by: whats_up_skip on January 08, 2009, 01:26:52 am
Wow that was fast and Thanks again.

We need to change your status from "Coppermine frequent poster" to Coppermine Legend".
Title: Re: Dynamic meta descriptions
Post by: MAGIKS on March 25, 2009, 08:36:46 am
found a bug in this mod,

file index.php

url in the user galleries stop working

*url's removed*
Title: Re: Dynamic meta descriptions
Post by: Ludo on March 25, 2009, 09:48:55 am
This doesn't look like a CPG-powered site at all...
Title: Re: Dynamic meta descriptions
Post by: Hein Traag on March 25, 2009, 10:57:01 am
@Magiks: Instead of posting url's that look fishy you might want to clarify what the bug is about.
Title: Re: Dynamic meta descriptions
Post by: Ludo on March 25, 2009, 11:41:06 am
Just for your information: I clicked on the 2 removed links and opened that site's homepage; now, I got 3 automated replies from forum@coppermine-gallery.net, despite I didn't send any email to that address.
Consider removing MAGIKS account.
Title: Re: Dynamic meta descriptions
Post by: Hein Traag on March 25, 2009, 12:31:07 pm
Done. Thanks for the alert Ludo.
Title: Re: Dynamic meta descriptions
Post by: MAGIKS on March 26, 2009, 09:00:20 pm
I am sorry for some misunderstandings which have arisen at my first attempt to inform about a error in this mod for the Coppermine gallery. Here detailed step-by-step infomation.

First, I installed latest release 1.4.21, then apply Ludo's mod "Dynamic meta descriptions", then turn on ability creating private user albums and created some public albums and categories. Then I uploaded some test images to all galleries.

All is fine, but all private user galleries didn't accessible (they numbers start from 10001, for example /index.php?cat=10001) gallery says "The selected category does not exist", however another public categories (which ID stats from 1) still accessible.

File index.php
Code: [Select]
$result = cpg_db_query("SELECT description FROM {$CONFIG['TABLE_CATEGORIES']} WHERE cid = '$cat'");
At attempt to access private user galleries (categories) we looking in the table "categories" for the CID 10001, but actually table have CID 1 for this category.

Title: Re: Dynamic meta descriptions
Post by: Ludo on March 26, 2009, 11:57:12 pm
In file index.php, find
Code: [Select]
        if (mysql_num_rows($result) == 0)
           cpg_die(CRITICAL_ERROR, $lang_errors['non_exist_cat'], __FILE__, __LINE__);
        list($cat_desc) = mysql_fetch_array($result);       
        if ($PAGE > 1) $cat_desc .= " - " . $lang_index_php['page'] . " $PAGE";

and change it to
Code: [Select]
        if (mysql_num_rows($result) > 0) {
            list($cat_desc) = mysql_fetch_array($result);       
            if ($PAGE > 1) $cat_desc .= " - " . $lang_index_php['page'] . " $PAGE";
        }

Mod code updated.
Title: Re: Dynamic meta descriptions
Post by: Astroman on June 16, 2009, 04:29:30 pm
Hi, this is a great mod. One thing I think would be good is if you limit the number of words in your description meta tags, because if you write like a whole paragraph for an image description the meta tag will also be a whole pragraph of text won't it? I think Google etc prefer the description meta to be a maximum of about 200 characters, your page here: http://vanrokken.altervista.org/displayimage.php?album=lastup&cat=0&pos=32 for instance has 270 characters in the description, which is too long according to this tool: http://www.seocentro.com/tools/search-engines/metatag-analyzer.html

Although I wouldn't bother about 270 characters being too much, but if it was 500 I might? :)
Title: Re: Dynamic meta descriptions
Post by: Ludo on June 17, 2009, 09:52:59 am
Good point!
Mod code updated, now meta descriptions are truncated at the position of the first blank space after the 170th character (to manage long words without exceeding 200 words in any case).

Direct link to the MOD's code (http://forum.coppermine-gallery.net/index.php/topic,43650.msg226432.html#msg226432) [edit by PYAP]
Title: Re: Dynamic meta descriptions
Post by: Astroman on June 17, 2009, 04:26:12 pm
Nice one. :)
Title: Re: Dynamic meta descriptions - some more staff
Post by: natalina on July 12, 2009, 10:16:57 am
Hi 8)Thanks to Ludo I've got meta descriptions  almost for alll cats etc. But later on due to Webmaster tols I found that there are still many pages with identical descriptions. It's all about user's galleries: albums have descriptions, but cats don't. I hardly can coding so my solution is stupid but I'll show it hoping that somebody will improve it:
In file index.php, find
]Code:
if (!empty($cat_desc))
Add above it
 
if (empty($cat_desc))
   $meta_description = strip_tags(bb_decode($cat)) . ' - ' . $CONFIG['gallery_name'];;
mysql_free_result($result);
Title: Re: Dynamic meta descriptions
Post by: Ludo on July 13, 2009, 10:21:10 am
This mod adds meta description tag to categories pages too: each page will have a different description as long as each category has a different title. In my CPG I don't have user galleries, so I can't figure out any mod misbehaviour related to them...
Title: Re: Dynamic meta descriptions
Post by: natalina on July 14, 2009, 07:25:34 am
Ludo, thank you for your answer -you are absolutely right: due to your mod every category do has meta description. But user galleries are formed in a different way, that's why I've made the small modification in order to prevent canonical issue. Naturally I don't mean that you personally have to brush it up. But maybe someone who have user galleries...
Title: Re: Dynamic meta descriptions
Post by: Ludo on July 14, 2009, 12:16:00 pm
Huh, I got it! Forgot my previous reply and thanks for your suggestion. Mod code updated accordingly.
Title: Re: Dynamic meta descriptions
Post by: natalina on July 14, 2009, 12:53:25 pm
Ludo, thanks  - it wasn't easy to get it because of my awful English(
Title: Re: Dynamic meta descriptions
Post by: aftab1003 on October 16, 2009, 02:27:43 pm
thanks LUDO


i am very happy to with your mod to dynamic description. i have done it my my gallery. @ http://picturerating.us/picture-gallery/index.php

i want to know if there is any possiblity to make dynamic titles with some alteration in your code, i am looking for dynamic titles. i have started the thread for this help, but nothing found related to this. if you guide me, that will be great for cpg users.
http://forum.coppermine-gallery.net/index.php/topic,62105.0.html
Title: Re: Dynamic meta descriptions
Post by: natalina on November 12, 2009, 11:39:36 am
Ludo, because of I have a lot of user's galleries I wasn't satisfied with my own solution - not only because of SEO: numbers in description can't tell anything to people. So at least I found the solution that seems more people friendly for me. Maybe you'll find it useful:
find
 if (empty($cat_desc))
   $meta_description = strip_tags(bb_decode($cat)) . ' - ' . $CONFIG['gallery_name'];
mysql_free_result($result);
& replace it with

$user_name = get_username($cat - FIRST_USER_CAT);
   $meta_description = strip_tags(bb_decode($user_name)) . ' - ' . $lang_list_categories['home']. ' - ' .$CONFIG['gallery_name'];
mysql_free_result($result);
Title: Re: Dynamic meta descriptions
Post by: Ludo on November 12, 2009, 02:16:57 pm
You seem to refer to a previous version of this mod: in the actual one user galleries are better managed ;)
Title: Re: Dynamic meta descriptions
Post by: natalina on November 12, 2009, 02:44:59 pm
 :) You are right - code is already updated.
Title: Re: Dynamic meta descriptions
Post by: natalina on November 12, 2009, 03:08:27 pm
And what about title like this:
if (empty($cat_desc)) $page_title = strip_tags(bb_decode($user_name)) . ' - ' . $lang_list_categories['home']; 

As for me it looks better than breadcrumbs     
Title: Re: Dynamic meta descriptions
Post by: Saif on November 23, 2009, 04:48:21 pm
DYNAMIC META DESCRIPTION TAGS MOD
This mod adds dynamic meta description tags to almost every page (categories, albums and images).
Meta description tag is filled respectively with category description, album description and image caption text, or, if it's not set, with a default site description set in config.inc.php.
HTML/BBCode tags stripped before building meta tag, if necessary.
Page number added both to meta description and page title in thumbnails page to avoid duplications when album spreads over multiple pages.
Thanks to GauGau for the hints above.

Files to edit:
include/config.inc.php
displayimage.php
index.php
thumbnails.php
lang/your_lang.php



OPEN
include/config.inc.php

FIND (at the end of file):
Code: [Select]
?>
BEFORE, ADD
Code: [Select]
// DEFAULT META DESCRIPTION TEXT
$CONFIG['meta_description'] = 'Your site default meta description text';


OPEN
displayimage.php

FIND (line 316)
Code: [Select]
if ($CURRENT_PIC_DATA['keywords']) { $meta_keywords = "<meta name=\"keywords\" content=\"".$CURRENT_PIC_DATA['keywords']."\"/>"; }
AFTER, ADD
Code: [Select]
    $meta_description = empty($CURRENT_PIC_DATA['caption']) ? $CONFIG['meta_description'] : strip_tags(bb_decode($CURRENT_PIC_DATA['caption']));
    $desc_len = strlen($meta_description);
    if (!is_numeric($album)) $desc_len += strlen($album_name)+3;
    if ($desc_len > 200) {
        $offset = 170;
        if (!is_numeric($album)) $offset -= strlen($album_name)+3;    
        $meta_description = substr($meta_description, 0, strpos($meta_description, " ", $offset))."...";                    
    }
    if (!is_numeric($album)) $meta_description .= " - " . $album_name;            
    $meta_description = "\n<meta name=\"description\" content=\"$meta_description\" />\n";
    $meta_keywords .= $meta_description;


OPEN
index.php

FIND (line 756)
Code: [Select]
if (isset($cat)) {
BEFORE, ADD
Code: [Select]
$meta_description = $CONFIG['meta_description'];
FIND (line 757)
Code: [Select]
get_meta_album_set($cat,$META_ALBUM_SET);
AFTER, ADD
Code: [Select]
$result = cpg_db_query("SELECT description FROM {$CONFIG['TABLE_CATEGORIES']} WHERE cid = '$cat'");
if (mysql_num_rows($result) > 0) list($cat_desc) = mysql_fetch_array($result);
if (!empty($cat_desc)) {
   $meta_description = strip_tags(bb_decode($cat_desc));
} else if ($cat >= FIRST_USER_CAT) {
   $user_name = get_username($cat - FIRST_USER_CAT);
   if (!$user_name) $user_name = 'Mr. X';
   $meta_description = sprintf($lang_list_categories['xx_s_gallery'], $user_name);
}
mysql_free_result($result);

FIND (line 764)
Code: [Select]
   pageheader($BREADCRUMB_TEXT ? $BREADCRUMB_TEXT : $lang_index_php['welcome']);
REPLACE WITH
Code: [Select]
    $desc_len = strlen($meta_description);
    if (isset($_GET['cat']) && $PAGE > 1) $desc_len += strlen($lang_index_php['page'] . " $PAGE")+3;
    if ($desc_len > 200) {
        $offset = 170;
        if (isset($_GET['cat']) && $PAGE > 1) $offset -= strlen($lang_index_php['page'] . " $PAGE")+3;    
        $meta_description = substr($meta_description, 0, strpos($meta_description, " ", $offset))."...";                            
    }
    if (isset($_GET['cat']) && $PAGE > 1) $meta_description .= " - " . $lang_index_php['page'] . " $PAGE";    
    $meta_description = "<meta name=\"description\" content=\"$meta_description\" />\n";
    $page_title = ($BREADCRUMB_TEXT) ? $BREADCRUMB_TEXT : $lang_index_php['welcome'];
    if (isset($_GET['cat']) && $PAGE > 1) $page_title .= " - " . $lang_index_php['page'] . " $PAGE";      
    pageheader($page_title, $meta_description);


OPEN
thumbnails.php

FIND (line 163)
Code: [Select]
pageheader(isset($CURRENT_ALBUM_DATA) ? $CURRENT_ALBUM_DATA['title'] : $lang_meta_album_names[$album]);
REPLACE WITH
Code: [Select]
$page_title = (isset($CURRENT_ALBUM_DATA) ? $CURRENT_ALBUM_DATA['title'] : $lang_meta_album_names[$album]);
$meta_description = isset($CURRENT_ALBUM_DATA['description']) ? strip_tags(bb_decode($CURRENT_ALBUM_DATA['description'])) : $CONFIG['meta_description'];
$desc_len = strlen($meta_description);
if (isset($CURRENT_ALBUM_DATA)) $desc_len += strlen($lang_meta_album_names[$album])+3;
if ($page > 1) $desc_len += strlen($lang_thumbnails_php['page'] . " $page")+3;
if ($desc_len > 200) {
    $offset = 170;
    if (isset($CURRENT_ALBUM_DATA)) $offset -= strlen($lang_meta_album_names[$album])+3;
    if ($page > 1) $offset -= strlen($lang_thumbnails_php['page'] . " $page")+3;    
    $meta_description = substr($meta_description, 0, strpos($meta_description, " ", $offset))."...";                    
}
if (!isset($CURRENT_ALBUM_DATA)) $meta_description .= " - " . $lang_meta_album_names[$album];
if ($page > 1) {
    $page_title .= " - " . $lang_thumbnails_php['page'] . " $page";
    $meta_description .= " - " . $lang_thumbnails_php['page'] . " $page";
}
$meta_description = "<meta name=\"description\" content=\"$meta_description\" />\n";
pageheader($page_title, $meta_description);


OPEN
lang/your_lang.php

FIND (line 1282)
Code: [Select]
);

$lang_album_admin_menu = array(

BEFORE, ADD (translate "Page" in your_lang!)
Code: [Select]
 'page' => 'Page',  
FIND (line 1714)
Code: [Select]
// ------------------------------------------------------------------------- //
// File thumbnails.php
// ------------------------------------------------------------------------- //


AFTER, ADD (translate "Page" in your_lang!)
Code: [Select]
if (defined('THUMBNAILS_PHP')) $lang_thumbnails_php = array(
  'page' => 'Page'
);

FIND AND DELETE (line below)
Code: [Select]
// Void

SAVE AND CLOSE ALL FILES

I have installed this mod : hopefully this will give me a better SEO...

http://www.orangewallpapers.com

( plz excuse my noobness)  Is it installed correctly at my gallery ? I'm unsure....  Any suggestions plz ?
Title: Re: Dynamic meta descriptions
Post by: Luksi1 on December 08, 2009, 11:30:28 am
Hi,
It´s a great mod for begining, but would it be possible to use category or album names for meta keywords on index.php

Thx

Luka
Title: Re: Dynamic meta descriptions
Post by: mikie on April 11, 2010, 01:33:19 pm
Ludo thks
It´s a needed mod, espessialy for search engines.
I have installed this for fotogallery of Kaluga city (http://kalugafoto.com/)
Title: Re: Dynamic meta descriptions
Post by: CaptainDEEZ on May 26, 2011, 04:13:07 am
I would start a new topic for "Custom Title and description for each page" , but I see information here that could be what I need.   I'm not exactly sure what I'm looking at, but could somebody please tell me which code in this section I'll have to modify to achieve SEO friendly titles and descriptions for each page?