Dynamic meta descriptions Dynamic meta descriptions
 

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]

Main Menu

Dynamic meta descriptions

Started by wipqozn1, May 08, 2007, 06:00:20 PM

Previous topic - Next topic

0 Members and 6 Guests are viewing this topic.

wipqozn1

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]


Joachim Müller

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.

wipqozn1

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:

    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}" />

Joachim Müller

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?

wipqozn1

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.

Joachim Müller

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?

wipqozn1

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:

<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?

Joachim Müller

To change the meta tag of the FAQ page, edit faq.php, findpageheader($lang_faq_php['faq']);and replace with$meta_description = '<meta name="Description" content="Często zadawane pytania on our gaming site" />';
pageheader($lang_faq_php['faq'], $meta_description );
Simple as that.

wipqozn1

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:

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

Is this okay?


$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);


Joachim Müller

Why don't you just try and give us feedback?

Walkinman

Hey Folks,

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

Thank you.

Cheers

Carl

wipqozn1

It works:

$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:

        $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.

Brane29

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!

Joachim Müller

Quote from: GauGau on May 10, 2007, 03:57:34 PMWhy 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?".

Brane29

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

Thanx

Joachim Müller


Brane29

Quote from: GauGau on June 06, 2007, 01:37:36 PM


"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!

Joachim Müller

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

Brane29

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!

Ludo

#19
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):
?>

BEFORE, ADD
// DEFAULT META DESCRIPTION TEXT
$CONFIG['meta_description'] = 'Your site default meta description text';



OPEN
displayimage.php

FIND (line 316)
if ($CURRENT_PIC_DATA['keywords']) { $meta_keywords = "<meta name=\"keywords\" content=\"".$CURRENT_PIC_DATA['keywords']."\"/>"; }

AFTER, ADD
    $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)
if (isset($cat)) {

BEFORE, ADD
$meta_description = $CONFIG['meta_description'];

FIND (line 757)
get_meta_album_set($cat,$META_ALBUM_SET);

AFTER, ADD
$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)
   pageheader($BREADCRUMB_TEXT ? $BREADCRUMB_TEXT : $lang_index_php['welcome']);

REPLACE WITH
    $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)
pageheader(isset($CURRENT_ALBUM_DATA) ? $CURRENT_ALBUM_DATA['title'] : $lang_meta_album_names[$album]);

REPLACE WITH
$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)
);

$lang_album_admin_menu = array(


BEFORE, ADD (translate "Page" in your_lang!)
 'page' => 'Page',  

FIND (line 1714)
// ------------------------------------------------------------------------- //
// File thumbnails.php
// ------------------------------------------------------------------------- //



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


FIND AND DELETE (line below)
// Void


SAVE AND CLOSE ALL FILES