Dynamic meta descriptions - Page 3 Dynamic meta descriptions - Page 3
 

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

Dynamic meta descriptions

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

Previous topic - Next topic

0 Members and 3 Guests are viewing this topic.

Hein Traag

@Magiks: Instead of posting url's that look fishy you might want to clarify what the bug is about.

Ludo

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.

Hein Traag

Done. Thanks for the alert Ludo.

MAGIKS

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


Ludo

In file index.php, find
        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
        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.

Astroman

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

Ludo

#46
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 [edit by PYAP]

Astroman


natalina

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

Ludo

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

natalina

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

Ludo

Huh, I got it! Forgot my previous reply and thanks for your suggestion. Mod code updated accordingly.

natalina

Ludo, thanks  - it wasn't easy to get it because of my awful English(

aftab1003

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

natalina

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

Ludo

You seem to refer to a previous version of this mod: in the actual one user galleries are better managed ;)

natalina

 :) You are right - code is already updated.

natalina

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     

Saif

Quote from: 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):
?>

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

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 ?

Luksi1

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