MetaTags not working - Update! - User error

phpBB SEO Premod for phpBB3 support forum.
This premodded version of phpBB3 includes the three different type of URL rewriting for phpBB3 by phpBB SEO. It comes with several other Search Engine Optimization mods installed.

Moderator: Moderators

MetaTags not working - Update! - User error

Postby allan1015 » Thu Mar 03, 2011 11:31 am

In case you read my other post this problem is with prosilver and my custom style

Have SEO Premod 3.0.8 installed, most everything works, except the Metatags I configured in the ACP, phpbb seo, extended settinsga re not showing on the page source.

All I get is the Board Description and the keywords are the board description with commas between words.

The Copyright info Meta tag is coming through correctly
The data is stored in the phpbb_config table as it should be

Any advice?
Last edited by allan1015 on Sun Mar 06, 2011 3:25 am, edited 2 times in total.
allan1015
 
Posts: 9
Joined: Thu Mar 03, 2011 6:55 am

Advertisement

Re: MetaTags not working

Postby allan1015 » Thu Mar 03, 2011 12:39 pm

What I found is this

in phpbb_seo_meta_.php the function make_keywords is being called with the site description instead of the meta keywords I entered
however the $this->meta_def variable is getting filled prpoerly

The following hack fixes the issue:

Code: Select all
/**
   * Returns a coma separated keyword list
   */
   function make_keywords($text, $decode_entities = false) {
      static $filter = array('`&(amp;)?[^;]+;`i', '`[[:punct:]]+`', '`[0-9]+`',  '`[\s]+`');
//hack
      $text = $this->meta_def['keywords'];
//End hack


I am not suggesting this hack as a fix, only as a diagnostic
I am unclear how make_keywords is being called, and from where.
allan1015
 
Posts: 9
Joined: Thu Mar 03, 2011 6:55 am

Re: MetaTags not working

Postby allan1015 » Thu Mar 03, 2011 1:19 pm

This is a definetly a bug! Its is causing Keyword and Definition to be taken from the Site adn not the Mata informatio

In the file mentoned abovein the build_meta function - see the ** note below

its seems that somewhere meta['keyword'] is getting set where it should be meta_def['keyword']
(same for description and maybe title and robots)

Code: Select all
      foreach ($this->tpl as $key => $value) {
         if (isset($this->meta[$key])) {    **this is passing for meta_def valaues like 'keyword' and it shouldnt be**
            // do like this so we can deactivate one particular tag on a given page,
            // by just setting the meta to an empty string
            if (trim($this->meta[$key])) {
               $this->meta[$key] = isset($this->filters[$key]) ? $this->{$this->filters[$key]}($this->meta[$key]) : $this->meta[$key];
                }
         } else if (!empty($this->meta_def[$key])) {
            $this->meta[$key] = isset($this->filters[$key]) ? $this->{$this->filters[$key]}($this->meta_def[$key]) : $this->meta_def[$key];
         }
         if (trim($this->meta[$key])) {
            $meta_code .= sprintf($value, utf8_htmlspecialchars($this->meta[$key])) . "\n";
         }
      }
allan1015
 
Posts: 9
Joined: Thu Mar 03, 2011 6:55 am

Re: MetaTags not working

Postby allan1015 » Thu Mar 03, 2011 1:42 pm

This code seems to fix it for me, still dont know what meta['keywords'] is not empty, but at least my site works

Code: Select all
foreach ($this->tpl as $key => $value) {
         if (isset($this->meta[$key]) ) {
            // do like this so we can deactivate one particular tag on a given page,
            // by just setting the meta to an empty string
            if (trim($this->meta[$key])) {
               $this->meta[$key] = isset($this->filters[$key]) ? $this->{$this->filters[$key]}($this->meta[$key]) : $this->meta[$key];
                }
         } else if (!empty($this->meta_def[$key])) {
            $this->meta_def[$key] = isset($this->filters[$key]) ? $this->{$this->filters[$key]}($this->meta_def[$key]) : $this->meta_def[$key];
         }
         if (trim($this->meta_def[$key])) {
            $meta_code .= sprintf($value, utf8_htmlspecialchars($this->meta_def[$key])) . "\n";
         } else if (trim($this->meta[$key])) {
            $meta_code .= sprintf($value, utf8_htmlspecialchars($this->meta[$key])) . "\n";
         }
      }
allan1015
 
Posts: 9
Joined: Thu Mar 03, 2011 6:55 am

Re: MetaTags not working

Postby allan1015 » Thu Mar 03, 2011 6:28 pm

Well this was fun, seriously,
I studied more of how the code was working, I certainly don't recommend my hack above

Hopefully the developers will understand this

The logic in the code above says
if meta['keyword'] exist use it else use the meta_def['keyword']

The problem is that meta[] values (keyword, title, description) seem to always exists, they get collected from various pages - so the meta_def[] values never get used.

The logic should be to use meta_def[] values if they exist, else use the meta value

I flipped my logic and every thing seems to be fine
allan1015
 
Posts: 9
Joined: Thu Mar 03, 2011 6:55 am

Re: MetaTags not working - Definate Bug

Postby SeO » Fri Mar 04, 2011 8:15 am

allan1015 wrote:The logic should be to use meta_def[] values if they exist, else use the meta value


You certainly do not want this. The only interest in using meta tags is if they are unique, especially for the meta description since it my be used by search engine in result list snippets.
Also, things like always adding default value in dynamic one is not a good idea since again it will not result in any SERP boost but rather into less specific thus mess efficient meta tags (since in such case the page may just not contain the keywords and the desc may not describe it either).

As you noticed, for index, forum and topic (including posts) meta keywords/desc are always defined by the mod, but it's not necessarily the case for all possible pages (including the one you may add).

You can specify keywords and description in any page by just adding :
Code: Select all
// www.phpBB-SEO.com SEO TOOLKIT BEGIN - META
$seo_meta->collect('description', "the description you want, can be a variable");
$seo_meta->collect('keywords', "the keywords you want, can be a variable");
// www.phpBB-SEO.com SEO TOOLKIT END - META

before page_header is called.
SeO
Admin
Admin
 
Posts: 6334
Joined: Wed Mar 15, 2006 9:41 pm

Re: MetaTags not working - Definate Bug

Postby allan1015 » Fri Mar 04, 2011 4:27 pm

SeO wrote:You certainly do not want this.

Dah -of course,
I understand your point about changing the meta tags to be context/page sensitive.
However I did not like using the Site Description as the meta tags that were put in, I wanted the default tags to be used for the home page.
For example I uses phrases like independently operated in the description but did not like that appearing in the meta tags. It is important for the user to read, it isnt important for Google to care about. IMHO

I will apply your change above to the index.php. - But shouldnt the code also pull from the description of the main forums listed on the index page? perhaps it does and theose words got cut off.
allan1015
 
Posts: 9
Joined: Thu Mar 03, 2011 6:55 am

Re: MetaTags not working - Definate Bug

Postby SeO » Sat Mar 05, 2011 12:55 pm

Using phpBBite desc and site title for the index.php meta tags does make sense IMHO, since they should be describing it well. Now, as said, you can use something else for your index meta, or just do not use the site description for anything but to describe the forum.
SeO
Admin
Admin
 
Posts: 6334
Joined: Wed Mar 15, 2006 9:41 pm


Return to phpBB SEO Premod

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 7 guests