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] 2 3 4   Go Down

Author Topic: Dynamic meta descriptions  (Read 63978 times)

0 Members and 1 Guest are viewing this topic.

wipqozn1

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 60
Dynamic meta descriptions
« 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]

« Last Edit: October 08, 2007, 08:09:23 pm by GauGau »
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Dynamic meta descriptions
« Reply #1 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.
Logged

wipqozn1

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 60
Re: Dynamic meta descriptions
« Reply #2 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}" />
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Dynamic meta descriptions
« Reply #3 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?
Logged

wipqozn1

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 60
Re: Dynamic meta descriptions
« Reply #4 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.
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Dynamic meta descriptions
« Reply #5 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?
Logged

wipqozn1

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 60
Re: Dynamic meta descriptions
« Reply #6 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?
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Dynamic meta descriptions
« Reply #7 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.
Logged

wipqozn1

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 60
Re: Dynamic meta descriptions
« Reply #8 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);

Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Dynamic meta descriptions
« Reply #9 on: May 10, 2007, 03:57:34 pm »

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

Walkinman

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 376
    • Skolai Images - Nature, Travel and Adventure stock photos
Re: Dynamic meta descriptions
« Reply #10 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
Logged

wipqozn1

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 60
Re: Dynamic meta descriptions
« Reply #11 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.
Logged

Brane29

  • Coppermine newbie
  • Offline Offline
  • Posts: 19
Re: Dynamic meta descriptions
« Reply #12 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!
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Dynamic meta descriptions
« Reply #13 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?".
Logged

Brane29

  • Coppermine newbie
  • Offline Offline
  • Posts: 19
Re: Dynamic meta descriptions
« Reply #14 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

Thanx
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Dynamic meta descriptions
« Reply #15 on: June 06, 2007, 01:37:36 pm »

we have no idea about Joomla and how it works.
Logged

Brane29

  • Coppermine newbie
  • Offline Offline
  • Posts: 19
Re: Dynamic meta descriptions
« Reply #16 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!
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Dynamic meta descriptions
« Reply #17 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
Logged

Brane29

  • Coppermine newbie
  • Offline Offline
  • Posts: 19
Re: Dynamic meta descriptions
« Reply #18 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!
Logged

Ludo

  • Contributor
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 706
    • E+GiElle
Re: Dynamic meta descriptions
« Reply #19 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
« Last Edit: July 14, 2009, 12:22:19 pm by Ludo »
Logged
Pages: [1] 2 3 4   Go Up
 

Page created in 0.035 seconds with 18 queries.