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 63983 times)

0 Members and 1 Guest are viewing this topic.

Hein Traag

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: nl
  • Offline Offline
  • Gender: Male
  • Posts: 2166
  • A, B, Cpg
    • Personal website - Spintires.nl
Re: Dynamic meta descriptions
« Reply #40 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.
Logged

Ludo

  • Contributor
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 706
    • E+GiElle
Re: Dynamic meta descriptions
« Reply #41 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.
Logged

Hein Traag

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: nl
  • Offline Offline
  • Gender: Male
  • Posts: 2166
  • A, B, Cpg
    • Personal website - Spintires.nl
Re: Dynamic meta descriptions
« Reply #42 on: March 25, 2009, 12:31:07 pm »

Done. Thanks for the alert Ludo.
Logged

MAGIKS

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 14
  • We are collecting a digital "art apples"
    • Vector Images and cliparts
Re: Dynamic meta descriptions
« Reply #43 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.

Logged

Ludo

  • Contributor
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 706
    • E+GiElle
Re: Dynamic meta descriptions
« Reply #44 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.
Logged

Astroman

  • Coppermine newbie
  • Offline Offline
  • Posts: 10
Re: Dynamic meta descriptions
« Reply #45 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? :)
Logged

Ludo

  • Contributor
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 706
    • E+GiElle
Re: Dynamic meta descriptions
« Reply #46 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 [edit by PYAP]
« Last Edit: June 17, 2009, 10:53:54 am by Pascal YAP »
Logged

Astroman

  • Coppermine newbie
  • Offline Offline
  • Posts: 10
Re: Dynamic meta descriptions
« Reply #47 on: June 17, 2009, 04:26:12 pm »

Nice one. :)
Logged

natalina

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Female
  • Posts: 96
    • Interior & Architecture
Re: Dynamic meta descriptions - some more staff
« Reply #48 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);

Ludo

  • Contributor
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 706
    • E+GiElle
Re: Dynamic meta descriptions
« Reply #49 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...
Logged

natalina

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Female
  • Posts: 96
    • Interior & Architecture
Re: Dynamic meta descriptions
« Reply #50 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...

Ludo

  • Contributor
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 706
    • E+GiElle
Re: Dynamic meta descriptions
« Reply #51 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.
Logged

natalina

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Female
  • Posts: 96
    • Interior & Architecture
Re: Dynamic meta descriptions
« Reply #52 on: July 14, 2009, 12:53:25 pm »

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

aftab1003

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 67
    • PictureRating Site for Teens
Re: Dynamic meta descriptions
« Reply #53 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
Logged

natalina

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Female
  • Posts: 96
    • Interior & Architecture
Re: Dynamic meta descriptions
« Reply #54 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);

Ludo

  • Contributor
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 706
    • E+GiElle
Re: Dynamic meta descriptions
« Reply #55 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 ;)
Logged

natalina

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Female
  • Posts: 96
    • Interior & Architecture
Re: Dynamic meta descriptions
« Reply #56 on: November 12, 2009, 02:44:59 pm »

 :) You are right - code is already updated.

natalina

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Female
  • Posts: 96
    • Interior & Architecture
Re: Dynamic meta descriptions
« Reply #57 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     

Saif

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 87
    • Free HD Wallpapers
Re: Dynamic meta descriptions
« Reply #58 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 ?
Logged

Luksi1

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 3
    • Tomatine
Re: Dynamic meta descriptions
« Reply #59 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
Logged
Pages: 1 2 [3] 4   Go Up
 

Page created in 0.035 seconds with 19 queries.