Advanced search  

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

Pages: 1 2 [3] 4   Go Down

Author Topic: Add Description Meta to Gallery <HEAD> and rel=canonical to META pages  (Read 89763 times)

0 Members and 1 Guest are viewing this topic.

neil fitzgerald

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 26
Re: Add Description Meta to Gallery <HEAD> and rel=canonical to META pages
« Reply #40 on: September 13, 2010, 04:27:12 am »

..but after adding the missing few lines (as attached) we have it working properly!
Thank you very much ;D
I hope there is something in this for others too.
Joe, if you can explain what's going on in layman's terms I'm interested (keen to learn and self help as much as possible).
Cheers,
Neil.


[edit] file removed - Joe Carver
« Last Edit: September 15, 2010, 02:09:48 am by Joe Carver »
Logged

Joe Carver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1545
  • aka 'i-imagine'
    • Home Page
Re: Add Description Meta to Gallery <HEAD> and rel=canonical to META pages
« Reply #41 on: September 13, 2010, 04:47:46 am »

..but after adding the missing few lines.....
....if you can explain what's going on.....
Why the lines have gone missing in the upload/download to and from here is beyond me.

Why the plugin worked differently I can answer more exactly to effect rather than root cause.

The plugin uses/used the variable $cat which (for me and my testing) returns the number of the current catalog. For some reason (the root cause) both of your setups returned an empty value for $cat which the plugin interpreted as a 0 (zero). It then used that 0 to return the description for the main album page.

I changed the plugin so that the catalog number is read through a Supercage get.
Code: [Select]
// grab category by supercage get
$superCage = Inspekt::makeSuperCage();
  if ($superCage->get->keyExists('cat')) {
$now_cat = $superCage->get->getInt('cat');
 }

I am glad that it works for you. Thanks for the testing info.
Now it will be time for another release.



Joe Carver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1545
  • aka 'i-imagine'
    • Home Page
Re: Add Description Meta to Gallery <HEAD> and rel=canonical to META pages
« Reply #42 on: September 15, 2010, 02:18:22 am »

Release of Version 1.5

    Changelog
    • Supercage get now used instead of $cat for category number

    To upgrade:
    Versions older than 1.4 must uninstall/delete/upload/reinstall.
    Back up your descriptions first.
    Version 1.4 can be upgraded by replacing codebase.php only.

    This might be more "friendly" to SEF urls - testing reports / results are requested.

    New version attached to first post in thread.

    nickelas

    • Coppermine frequent poster
    • ***
    • Offline Offline
    • Posts: 114
    Re: Add Description Meta to Gallery <HEAD> and rel=canonical to META pages
    « Reply #43 on: September 17, 2010, 11:34:28 am »

    Thank you for this plugin.
    One question, it looks like it adds the filename to the meta description if there is no description to the image. Could this be a config (to leave out the filename)?
    http://uppsalafoto.se/galleri/ 
    Logged
    Human

    Joe Carver

    • Dev Team member
    • Coppermine addict
    • ****
    • Country: us
    • Offline Offline
    • Gender: Male
    • Posts: 1545
    • aka 'i-imagine'
      • Home Page
    Re: Add Description Meta to Gallery <HEAD> and rel=canonical to META pages
    « Reply #44 on: September 17, 2010, 11:57:30 am »

    Could this be a config (to leave out the filename)?

    I will take a look for the next release.
    « Last Edit: September 17, 2010, 11:11:07 pm by Joe Carver »
    Logged

    profili

    • Coppermine frequent poster
    • ***
    • Offline Offline
    • Gender: Male
    • Posts: 113
    Re: Add Description Meta to Gallery <HEAD> and rel=canonical to META pages
    « Reply #45 on: January 04, 2011, 11:13:07 pm »

    The Canonical tag is not working when a file is visited from an album.
    E.g, the album http://www.galsh.com/thumbnails-22.html
    One photo in this album http://www.galsh.com/displayimage-22-46374.html#top_display_media
    As you can see no canonical tag here! Can you fix this please!
    Logged

    Joe Carver

    • Dev Team member
    • Coppermine addict
    • ****
    • Country: us
    • Offline Offline
    • Gender: Male
    • Posts: 1545
    • aka 'i-imagine'
      • Home Page
    Re: Add Description Meta to Gallery <HEAD> and rel=canonical to META pages
    « Reply #46 on: January 04, 2011, 11:42:48 pm »

    The Canonical tag is not working when a file is visited from an album.
    That is the intent of the design. The canonical tag would show only if you see that picture by clicking it from meta albums. (Lastup, Most viewed, Last comment, etc.)

    Canonical is in this Coppermine plugin to tell the search sites:
       "This meta page is related to the main image page."

    The main image page is always what the album page has for links.

    Can you fix this please!
    Try reading the links on the first page in this thread.
    There is nothing to fix here.

    profili

    • Coppermine frequent poster
    • ***
    • Offline Offline
    • Gender: Male
    • Posts: 113
    Re: Add Description Meta to Gallery <HEAD> and rel=canonical to META pages
    « Reply #47 on: January 05, 2011, 12:09:25 am »

    If the Google bot will visit this url http://www.galsh.com/displayimage-22-46374.html#top_display_media and there is no canonical tag, it will index it. But this is not the  permalink of this file. This is the permalink http://www.galsh.com/displayimage-46374.html
    That's why the canonical tag should work everytime if there are multiple URLs for the same content. I hope you understand what I mean. Thank you.
    Logged

    Joe Carver

    • Dev Team member
    • Coppermine addict
    • ****
    • Country: us
    • Offline Offline
    • Gender: Male
    • Posts: 1545
    • aka 'i-imagine'
      • Home Page
    Re: Add Description Meta to Gallery <HEAD> and rel=canonical to META pages
    « Reply #48 on: January 05, 2011, 12:33:02 am »

    What have you set in the plugin config for that variable? PID or AID + PID?



    Please bear in mind that SEF urls may change the behavior of the plugin too.


    This is the permalink......
    Where does that link come from? From which page does a search engine find it?

    profili

    • Coppermine frequent poster
    • ***
    • Offline Offline
    • Gender: Male
    • Posts: 113
    Re: Add Description Meta to Gallery <HEAD> and rel=canonical to META pages
    « Reply #49 on: January 05, 2011, 08:20:05 am »

    What have you set in the plugin config for that variable? PID or AID + PID?
    Please bear in mind that SEF urls may change the behavior of the plugin too.


    I use PID.

    Quote
    Where does that link come from? From which page does a search engine find it?

    Under "File information" is the unique url for each file. But more important for Google is to see only one url for one content. And Canonical tag is ideal for this.
    Logged

    profili

    • Coppermine frequent poster
    • ***
    • Offline Offline
    • Gender: Male
    • Posts: 113
    Re: Add Description Meta to Gallery <HEAD> and rel=canonical to META pages
    « Reply #50 on: January 10, 2011, 01:34:42 am »

    No chance to have here a complete solution for canonical tag for Copperimine Gallery, right?
    Logged

    Ulenka

    • Coppermine novice
    • *
    • Offline Offline
    • Posts: 32
    Re: Add Description Meta to Gallery <HEAD> and rel=canonical to META pages
    « Reply #51 on: October 18, 2012, 11:17:59 am »

    I want to add "Descriptions of album" in meta-description. Which code put into "Set Meta Description - Album List page"?
    Logged

    Joe Carver

    • Dev Team member
    • Coppermine addict
    • ****
    • Country: us
    • Offline Offline
    • Gender: Male
    • Posts: 1545
    • aka 'i-imagine'
      • Home Page

    It is difficult to understand which page(s) you are asking about.

    Please post a link to the exact page that you describe.

    Posting a link to your Coppermine is required by the Board Rules

    astrasuite

    • Coppermine novice
    • *
    • Offline Offline
    • Posts: 22

    Hi, Joe,

    Thanks for this plugin, excellent.

    Overall great.  It shows the same desc for urls like these though :

    http://www.astrasuite.com/client-system-albums/displayimage.php?album=129&pid=1659

    http://www.astrasuite.com/client-system-albums/displayimage.php?pid=1659


    Could it be possible to include an option to replace meta Title as well ?  With a random number generated to append at the end of the title to ensure all titles are unique (maybe done to meta description as well)


    Thanks
    Logged

    astrasuite

    • Coppermine novice
    • *
    • Offline Offline
    • Posts: 22

    p.s.  Never mind about the title, I was able to make it unique by modifying /include/themes.inc.php

    I just changed this :

    '{TITLE}' => theme_page_title($section),

    to this :

    '{TITLE}' => theme_page_title($section) . " | " . rand(1,1000),


    Maybe I'll do the same to the desc ...
    Logged

    astrasuite

    • Coppermine novice
    • *
    • Offline Offline
    • Posts: 22

    Never mind about the description too, I got it to be unique now, same with title.  While taking care of the recommended lengths by Google, I just append the last few characters of the current url to both title and description, rather than rand(), and it's always unique now, while being constant.

    So for my two examples above, same image but different url, no more duplicates.  Down from 2000+ reported by Google Webmaster to zero ...

    Thanks for the plugin ...
    Logged

    Walkinman

    • Coppermine frequent poster
    • ***
    • Offline Offline
    • Gender: Male
    • Posts: 380
      • Skolai Images - Nature, Travel and Adventure stock photos
    Re: Add Description Meta to Gallery <HEAD> and rel=canonical to META pages
    « Reply #56 on: December 31, 2013, 05:23:03 am »

    Is there a way to config this plugin so that it does NOT add a description tag to albums? I have tweaked things so I can write custom meta tags for description on my site (for album pages (and categories if I can figure that part out)), and it's causing 2 tags to be generated .. I would like to keep this plugin mainly for the image display pages.


    Astrasuite - would you mind posting how you did that for the description tag? I'm also getting tons of duplicate description tags on the google and would like to find an easier way to fix it than doing it manually. I played with the themes.inc.php file a bit but couldn't make anything work.

    Thanks.
    Logged

    Walkinman

    • Coppermine frequent poster
    • ***
    • Offline Offline
    • Gender: Male
    • Posts: 380
      • Skolai Images - Nature, Travel and Adventure stock photos
    Re: Add Description Meta to Gallery <HEAD> and rel=canonical to META pages
    « Reply #57 on: December 31, 2013, 06:23:41 am »

    PS: OK .. so I found a way to do add a description to the image display via this thread
    http://forum.coppermine-gallery.net/index.php/topic,17275.msg98259.html#msg98259
    Code: [Select]
    if ($CURRENT_PIC_DATA['title']) { $meta_keywords .= "<meta name=\"description\" content=\"".$CURRENT_PIC_DATA['caption']."\">"; }

    and I added this so they're not duplicates
    Code: [Select]
    if ($CURRENT_PIC_DATA['title']) { $meta_keywords .= "<meta name=\"description\" content=\"".$CURRENT_PIC_DATA['caption']. " | Image = #".$pid."\">"; }
    So the tag is constant and unique. So I think I have that figured out. Now, how to get my the meta tag to display on the category pages, and I think I'll be getting somewhere! Ideally I'd like to limit the caption in the meta tag to maybe 150 characters, but I don't know how to do that.

    Having got this done, I've uninstalled the plugin, Joe, so no need to address my earlier question about an option to NOT add a desc to albums. Unless it's of some value to others, of course.

    Thanks.

    Cheers

    Carl
    Logged

    astrasuite

    • Coppermine novice
    • *
    • Offline Offline
    • Posts: 22

    Sorry, Walkinman, didn't see this ... anyway, mine is a lot of change, and results may not be for everyone.

    Here is the whole codebase.php, I commented my changes with "jcr", and others have "jcr" so it's understandable ...

    Code: [Select]
    <?php
      
    /*******************************************************
       Add Meta Descriptions and canonical references 
       By Joe Carver 
    Version 1.5 - 14 September 2010 
      *******************************************************/
      
        
    require_once('include/init.inc.php');
        if (!
    defined('IN_COPPERMINE')) {die('Not in Coppermine...');}
    global $CONFIG$CPG_PHP_SELF$template_header;

    // Add plugin_install action
    $thisplugin->add_action('plugin_install','add_meta_install');

    // Add plugin_uninstall action
    $thisplugin->add_action('plugin_uninstall','add_meta_uninstall');

    function char_convert($str_a) {  // convert some characters if sanitized in db entry
    $str_a str_replace(array('&amp;''&quot;''&lt;''&gt;''&#38;#039;''&#38;#39;' '_' '-'), array('&''"''<''>'"'""'"'  ''  ') ,$str_a);
    return  $str_a;
    }
    // grab category by supercage get
    $superCage Inspekt::makeSuperCage();
    $now_cat '';
    if ($superCage->get->keyExists('cat')) {
    $now_cat $superCage->get->getInt('cat');
      }

    //  meta descrptions for category with albums
    if ($CPG_PHP_SELF == 'index.php' && $now_cat 0) {  
        
    $thisplugin->add_filter('theme_pageheader_params','add_meta_description');
    function add_meta_description($template_vars) {
        global  $CONFIG$LINEBREAK$template_header$meta$CURRENT_CAT_NAME;

    // jcr - get current url
    global $jcr_current_url;
     
    $jcr_current_url jcr_getCurrentUrl();
    $jcr_current_url str_replace('/','',substr($jcr_current_url,0));
            
    $jcr_current_url str_replace('-','',substr($jcr_current_url, -18));

    // grab category by supercage get
    $superCage Inspekt::makeSuperCage();
     
    if ($superCage->get->keyExists('cat')) {
    $now_cat $superCage->get->getInt('cat');
      }       
    $result cpg_db_query("SELECT description FROM {$CONFIG['TABLE_CATEGORIES']} WHERE cid = '$now_cat'");
            
    $row mysql_fetch_array($result);
            
    $this_cat char_convert(strip_tags(bb_decode($row['description'])));
    $this_cat str_replace('"','',substr($this_cat,0));
    mysql_free_result($result);

            
    $this_title substr(char_convert($CURRENT_CAT_NAME),0,135) . ' / ' $jcr_current_url;
    $this_title str_replace('"','',substr($this_title,0));
    if (strlen($this_title) < 130)
    $this_title $this_title ' / This is an album gallery of some client systems';
    if (strlen($this_title) < 100)
    $this_title $this_title ' / We supply high-end audio that respect music with emotion';
        if ($this_cat != '')  {
    $this_cat substr($this_cat,0,135) . ' / ' $jcr_current_url;
    if (strlen($this_cat) < 130)
    $this_cat $this_cat ' / This is an album gallery of some client systems';
    if (strlen($this_cat) < 100)
    $this_cat $this_cat ' / We supply high-end audio that respect music with emotion';
        $new_meta = <<< EOT
    <meta name="description" content="$this_cat" /> 
    EOT;
                } else  {
            $new_meta = <<< EOT
    <meta name="description" content="$this_title" /> 
    EOT;
        }

    $current_meta $template_vars['{META}'];
    $cat_meta = array('{META}' => $current_meta $new_meta);
    return array_merge($template_vars$cat_meta);

    }
        }

        
    // meta descrptions for albums
    if ($CPG_PHP_SELF == 'thumbnails.php') {
        
    $thisplugin->add_filter('theme_pageheader_params','add_meta_description');
    function add_meta_description($template_vars) {
            global 
    $album$aid$LINEBREAK$CONFIG$template_header$meta$page$lang_common;
    // jcr - get current url
    global $jcr_current_url;
     
    $jcr_current_url jcr_getCurrentUrl();
    $jcr_current_url str_replace('/','',substr($jcr_current_url,0));

    $jcr_current_url str_replace('-','',substr($jcr_current_url, -18));

        $result cpg_db_query("SELECT description, title FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid = '$album'");
            
    $row mysql_fetch_array($result);
            
    $this_alb strip_tags(bb_decode($row['description']));
    $this_alb str_replace('"','',substr($this_alb,0));
            
    $this_title substr(char_convert(strip_tags(bb_decode($row['title']))),0,135) . ' / ' $jcr_current_url;
    $this_title str_replace('"','',substr($this_title,0));
    if (strlen($this_title) < 130)
    $this_title $this_title ' / This is an album gallery of some client systems';
    if (strlen($this_title) < 100)
    $this_title $this_title ' / We supply high-end audio that respect music with emotion';
    mysql_free_result($result);

    $meta_robo_array = array( // exclude meta albums list
        
    'lastup',
        
    'lastcom',
        
    'topn',
        
    'toprated',
        
    'favpics',
        
    'random',
        
    'datebrowse',
    'lastcomby',
    'lastupby',
    'lasthits',
    'search',
    'lastalb',
    'favpics'
        );


        if ($page 0)  {
    $this_page_num ' Page' ' ' $page;
        } else  {
            $this_page_num '';
        }
        if ($this_alb != '')  {
    $this_alb =  substr($this_alb,0,135) . ' / ' $jcr_current_url;
    if (strlen($this_alb) < 130)
    $this_alb $this_alb ' / This is an album gallery of some client systems';
    if (strlen($this_alb) < 100)
    $this_alb $this_alb ' / We supply high-end audio that respect music with emotion';
    $alb_meta = <<< EOT
    <meta name="description" content="$this_alb . $this_page_num" /> 
    EOT;
            } else  {
            $this_title $this_title ' ' $lang_common['album'] . ' ' $this_page_num ' ';
            $alb_meta = <<< EOT
    <meta name="description" content="$this_title" /> 
    EOT;
    }
            
    $superCage Inspekt::makeSuperCage();
            if (
    in_array($superCage->get->getAlpha('album'), $meta_robo_array)) {
        $alb_meta '';
        } 

    $current_meta $template_vars['{META}'];
    $cat_meta = array('{META}' => $current_meta $alb_meta);
    return array_merge($template_vars$cat_meta);
    }
        }

    //  meta descrptions for Home Page
    // determine page location - home or first album list page
    $superCage Inspekt::makeSuperCage();
    if ($CPG_PHP_SELF == 'index.php' && !$superCage->get->keyExists('cat')) {

    $thisplugin->add_filter('theme_pageheader_params','add_meta_description');
    function add_meta_description($template_vars) {
        global $CONFIG$LINEBREAK$template_header$meta;

    // jcr - get current url
    global $jcr_current_url;
     
    $jcr_current_url jcr_getCurrentUrl();
    $jcr_current_url str_replace('/','',substr($jcr_current_url,0));

    $jcr_current_url str_replace('-','',substr($jcr_current_url, -18));

    $home_meta substr(char_convert($CONFIG['add_meta_home']),0,135) . ' / ' $jcr_current_url;
    $home_meta str_replace('"','',substr($home_meta,0));
    if (strlen($home_meta) < 130)
    $home_meta $home_meta ' / This is an album gallery of some client systems';
    if (strlen($home_meta) < 100)
    $home_meta $home_meta ' / We supply high-end audio that respect music with emotion';

        
    $new_meta = <<< EOT
    <meta name="description" content="$home_meta" />
    $LINEBREAK
    EOT;

    $current_meta $template_vars['{META}'];
    $cat_meta = array('{META}' => $current_meta $new_meta);
    return array_merge($template_vars$cat_meta);
    }
        }

    //  meta descrptions for main Album List Page
    $superCage Inspekt::makeSuperCage();
    if ($CPG_PHP_SELF == 'index.php' && $superCage->get->keyExists('cat') && $now_cat 1) {
    $thisplugin->add_filter('theme_pageheader_params','add_meta_description');
    function add_meta_description($template_vars) {
        global $CONFIG$LINEBREAK$template_header$meta;

    // jcr - get current url
    global $jcr_current_url;
     
    $jcr_current_url jcr_getCurrentUrl();
    $jcr_current_url str_replace('/','',substr($jcr_current_url,0));

    $jcr_current_url str_replace('-','',substr($jcr_current_url, -18));

        $alblist_meta substr(char_convert($CONFIG['add_meta_alblist']),0,135) . ' / ' $jcr_current_url;
    $alblist_meta str_replace('"','',substr($alblist_meta,0));
    if (strlen($alblist_meta) < 130)
    $alblist_meta $alblist_meta ' / This is an album gallery of some client systems';
    if (strlen($alblist_meta) < 100)
    $alblist_meta $alblist_meta ' / We supply high-end audio that respect music with emotion';
            
    $new_meta = <<< EOT
    <meta name="description" content="$alblist_meta" />
    $LINEBREAK
    EOT;

    $current_meta $template_vars['{META}'];
    $cat_meta = array('{META}' => $current_meta $new_meta);
    return array_merge($template_vars$cat_meta);
    }
        }
        

    //  meta descrptions for Search Page
    if ($CPG_PHP_SELF == 'search.php')
    {
        $thisplugin->add_filter('theme_pageheader_params','add_meta_description');
        function add_meta_description($template_vars) {
        global $CONFIG$LINEBREAK$template_header$meta;

    // jcr - get current url
    global $jcr_current_url;
     
    $jcr_current_url jcr_getCurrentUrl();
    $jcr_current_url str_replace('/','',substr($jcr_current_url,0));

    $jcr_current_url str_replace('-','',substr($jcr_current_url, -18));

        $search_meta substr(char_convert($CONFIG['add_meta_search']),0,135) . ' / ' $jcr_current_url;
    $search_meta str_replace('"','',substr($search_meta,0));
    if (strlen($search_meta) < 130)
    $search_meta $search_meta ' / This is an album gallery of some client systems';
    if (strlen($search_meta) < 100)
    $search_meta $search_meta ' / We supply high-end audio that respect music with emotion';
            
    $new_meta = <<< EOT
    <meta name="description" content="$search_meta" />
    $LINEBREAK
    EOT;

    $current_meta $template_vars['{META}'];
    $cat_meta = array('{META}' => $current_meta $new_meta);
    return array_merge($template_vars$cat_meta);
    }
        }

    //  meta descrptions for Picture Page
    if ($CPG_PHP_SELF == 'displayimage.php') {
    $thisplugin->add_filter('theme_pageheader_params','add_meta_description');

        function 
    add_meta_description($template_vars) {
        global $CONFIG$LINEBREAK$template_header$meta$CURRENT_PIC_DATA$lang_common$CURRENT_ALBUM_DATA$pic_pos;

    // jcr - get current url
    global $jcr_current_url;
     
    $jcr_current_url jcr_getCurrentUrl();
    $jcr_current_url str_replace('/','',substr($jcr_current_url,0));

    $jcr_current_url str_replace('-','',substr($jcr_current_url, -18));

    if ($CONFIG['add_meta_owner_name'] == 1)  {
    $pic_owner_number $CURRENT_PIC_DATA['owner_id'];
    $result cpg_db_query("SELECT user_name FROM {$CONFIG['TABLE_USERS']} WHERE user_id = '$pic_owner_number'");
            
    $row mysql_fetch_array($result);
            
    $pic_owner_name char_convert(strip_tags(bb_decode($row['user_name'])));
    mysql_free_result($result);
            }
    else  {
            
    $pic_owner_name '';
            }


    if ($CURRENT_PIC_DATA['caption'] != '') {
        $pic_meta char_convert(strip_tags(bb_decode($CURRENT_PIC_DATA['caption'])))  . '  ' $pic_owner_name ' ' char_convert($CONFIG['add_meta_pics']);
    $pic_meta substr($pic_meta,0,135) . ' / ' $jcr_current_url;
    $pic_meta str_replace('"','',substr($pic_meta,0));
    if (strlen($pic_meta) < 130)
    $pic_meta $pic_meta ' / This is an album gallery of some client systems';
    if (strlen($pic_meta) < 100)
    $pic_meta $pic_meta ' / We supply high-end audio that respect music with emotion';

            
    $new_meta = <<< EOT
    <meta name="description" content="$pic_meta" /> 

    EOT;
                } else  {
            $home_meta char_convert(strip_tags(bb_decode($CURRENT_PIC_DATA['title']))) . ' ' $lang_common['album'] . ' ' char_convert(strip_tags(bb_decode($CURRENT_ALBUM_DATA['title']))) . ' ' char_convert(strip_tags(bb_decode($CURRENT_PIC_DATA['filename']))) . ' ' $pic_owner_name ' ' char_convert($CONFIG['add_meta_pics']) . $pic_pos;
    $home_meta substr($home_meta,0,135) . ' / ' $jcr_current_url;
    $home_meta str_replace('"','',substr($home_meta,0));
    if (strlen($home_meta) < 130)
    $home_meta $home_meta ' / This is an album gallery of some client systems';
    if (strlen($home_meta) < 100)
    $home_meta $home_meta ' / We supply high-end audio that respect music with emotion';

                
    $new_meta = <<< EOT
    <meta name="description" content="$home_meta" />

    EOT;
    }

    $meta_robo_array = array( // array to not list description, but to add link rel="canonical
        
    'lastup',
        
    'lastcom',
        
    'topn',
        
    'toprated',
        
    'favpics',
        
    'random',
        
    'datebrowse',
    'lastcomby',
    'lastupby',
    'lasthits',
    'search',
    'lastalb',
    'favpics'
        );

        
    $superCage Inspekt::makeSuperCage();
        if (
    in_array($superCage->get->getAlpha('album'), $meta_robo_array)) {
    $this_album  $CURRENT_PIC_DATA['aid'];
    $this_file  $CURRENT_PIC_DATA['pid'];

        if (
    $CONFIG['add_meta_pid'] == 1)  {
    $this_pic  = <<< EOT
    displayimage.php?pid=$this_file
    EOT;

    }  else  {
    $this_pic  = <<< EOT
    displayimage.php?album=$this_album&pid=$this_file
    EOT;
        }

    $this_address $CONFIG['site_url'];
    $this_canon $this_address $this_pic;
       
    $new_meta = <<< EOT
    <link rel="canonical" href="$this_canon" />

    EOT;
        } 


    $current_meta $template_vars['{META}'];
    $cat_meta = array('{META}' => $current_meta $new_meta);

        return 
    array_merge($template_vars$cat_meta);
    }
        }


    //  meta descrptions for Contact Page
    if ($CPG_PHP_SELF == 'contact.php')
    {
        $thisplugin->add_filter('theme_pageheader_params','add_meta_description');
        function add_meta_description($template_vars) {
        global $CONFIG$LINEBREAK$template_header$meta;

    // jcr - get current url
    global $jcr_current_url;
     
    $jcr_current_url jcr_getCurrentUrl();
    $jcr_current_url str_replace('/','',substr($jcr_current_url,0));

    $jcr_current_url str_replace('-','',substr($jcr_current_url, -18));

        $contact_meta substr(char_convert($CONFIG['add_meta_contact']),0,135) . ' / ' $jcr_current_url;
    $contact_meta str_replace('"','',substr($contact_meta,0));
    if (strlen($contact_meta) < 130)
    $contact_meta $contact_meta ' / This is an album gallery of some client systems';
    if (strlen($contact_meta) < 100)
    $contact_meta $contact_meta ' / We supply high-end audio that respect music with emotion';

            
    $new_meta = <<< EOT
    <meta name="description" content="$contact_meta" />
    EOT;

    $current_meta $template_vars['{META}'];
    $cat_meta = array('{META}' => $current_meta $new_meta);
    return array_merge($template_vars$cat_meta);
    }
        }


    //  meta descrptions for Register Page
    if ($CPG_PHP_SELF == 'register.php')
    {
        $thisplugin->add_filter('theme_pageheader_params','add_meta_description');
        function add_meta_description($template_vars) {
        global $CONFIG$LINEBREAK$template_header$meta;

    // jcr - get current url
    global $jcr_current_url;
     
    $jcr_current_url jcr_getCurrentUrl();
    $jcr_current_url str_replace('/','',substr($jcr_current_url,0));

    $jcr_current_url str_replace('-','',substr($jcr_current_url, -18));

        $register_meta substr(char_convert($CONFIG['add_meta_register']),0,135) . ' / ' $jcr_current_url;
    $register_meta str_replace('"','',substr($register_meta,0));
    if (strlen($register_meta) < 130)
    $register_meta $register_meta ' / This is an album gallery of some client systems';
    if (strlen($register_meta) < 100)
    $register_meta $register_meta ' / We supply high-end audio that respect music with emotion';

            
    $new_meta = <<< EOT
    <meta name="description" content="$register_meta" />
    EOT;

    $current_meta $template_vars['{META}'];
    $cat_meta = array('{META}' => $current_meta $new_meta);
    return array_merge($template_vars$cat_meta);
    }
        }


    //  meta descrptions for Login Page
    if ($CPG_PHP_SELF == 'login.php')
    {
        $thisplugin->add_filter('theme_pageheader_params','add_meta_description');
        function add_meta_description($template_vars) {
        global $CONFIG$LINEBREAK$template_header$meta;

    // jcr - get current url
    global $jcr_current_url;
     
    $jcr_current_url jcr_getCurrentUrl();
    $jcr_current_url str_replace('/','',substr($jcr_current_url,0));

    $jcr_current_url str_replace('-','',substr($jcr_current_url, -18));

        $login_meta substr(char_convert($CONFIG['add_meta_login']),0,135) . ' / ' $jcr_current_url;
    $login_meta str_replace('"','',substr($login_meta,0));
    if (strlen($login_meta) < 130)
    $login_meta $login_meta ' / This is an album gallery of some client systems';
    if (strlen($login_meta) < 100)
    $login_meta $login_meta ' / We supply high-end audio that respect music with emotion';

            
    $new_meta = <<< EOT
    <meta name="description" content="$login_meta" />
    EOT;

    $current_meta $template_vars['{META}'];
    $cat_meta = array('{META}' => $current_meta $new_meta);
    return array_merge($template_vars$cat_meta);
    }
        }



    // Install the plugin
    function add_meta_install() {
    global $CONFIG$thisplugin;

    // add new meta to db
    cpg_db_query("INSERT IGNORE INTO {$CONFIG['TABLE_CONFIG']} (`name`, `value`) VALUES ('add_meta_home', 'Home Page Coppermine Photo Gallery')");
    cpg_db_query("INSERT IGNORE INTO {$CONFIG['TABLE_CONFIG']} (`name`, `value`) VALUES ('add_meta_alblist', 'Album List Main Page Coppermine Photo Gallery')");
    cpg_db_query("INSERT IGNORE INTO {$CONFIG['TABLE_CONFIG']} (`name`, `value`) VALUES ('add_meta_search', 'Search Page Coppermine Photo Gallery')");
    cpg_db_query("INSERT IGNORE INTO {$CONFIG['TABLE_CONFIG']} (`name`, `value`) VALUES ('add_meta_pics', 'picture')");
    cpg_db_query("INSERT IGNORE INTO {$CONFIG['TABLE_CONFIG']} (`name`, `value`) VALUES ('add_meta_owner_name', '1')");
    cpg_db_query("INSERT IGNORE INTO {$CONFIG['TABLE_CONFIG']} (`name`, `value`) VALUES ('add_meta_contact', 'Contact the admin of this Coppermine Photo Gallery')");
    cpg_db_query("INSERT IGNORE INTO {$CONFIG['TABLE_CONFIG']} (`name`, `value`) VALUES ('add_meta_register', 'Register an account on this Coppermine Photo Gallery')");
    cpg_db_query("INSERT IGNORE INTO {$CONFIG['TABLE_CONFIG']} (`name`, `value`) VALUES ('add_meta_pid', '1')");
    cpg_db_query("INSERT IGNORE INTO {$CONFIG['TABLE_CONFIG']} (`name`, `value`) VALUES ('add_meta_login', 'Login to the gallery')");
    return true;
    }


    // Uninstall the plugin
    function add_meta_uninstall() {
    global $CONFIG$thisplugin;

    //remove the record from config
    cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'add_meta_home'");
    cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'add_meta_alblist'");
    cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'add_meta_search'");
    cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'add_meta_pics'");
    cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'add_meta_owner_name'");
    cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'add_meta_contact'");
    cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'add_meta_register'");
    cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'add_meta_pid'");
    cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'add_meta_login'");
    return true;
    }

    function 
    jcr_getCurrentUrl() {
        
    $superCage Inspekt::makeSuperCage();
        
    $protocol $superCage->server->keyExists('HTTPS') && $superCage->server->getAlnum('HTTPS') == 'on'
          
    'https://'
          
    'http://';
        
    $currentUrl $protocol implode($superCage->server->getMatched('HTTP_HOST','/[a-zA-Z0-9\-\.\:]+/')) . implode($superCage->server->getMatched('REQUEST_URI','/[[:print:]]*/'));

        return 
    $currentUrl;


    ?>


    Is there a way to config this plugin so that it does NOT add a description tag to albums? I have tweaked things so I can write custom meta tags for description on my site (for album pages (and categories if I can figure that part out)), and it's causing 2 tags to be generated .. I would like to keep this plugin mainly for the image display pages.


    Astrasuite - would you mind posting how you did that for the description tag? I'm also getting tons of duplicate description tags on the google and would like to find an easier way to fix it than doing it manually. I played with the themes.inc.php file a bit but couldn't make anything work.

    Thanks.
    Logged

    astrasuite

    • Coppermine novice
    • *
    • Offline Offline
    • Posts: 22

    p.s.  It might be very crude to experts :), but it works for me so far ... I only get 1 Google Webmaster HTML Improvement "error", and that's due to Yoast Wordpress plugin.

    HTML Improvements
    Last updated Mar 27, 2014
    Addressing the following may help your site's user experience and performance.
    Meta description   Pages
    We didn't detect any issues with the meta descriptions on your site.
    Title tag   Pages
    Missing title tags   1
    Duplicate title tags   0
    Long title tags   0
    Short title tags   0
    Non-informative title tags   0
    Non-indexable content   Pages
    We didn't detect any issues with non-indexable content on your site.
    Logged
    Pages: 1 2 [3] 4   Go Up
     

    Page created in 0.04 seconds with 20 queries.