martedì 15 novembre 2011

Title tags: different methods... typoscript or php?

A while ago i set up some page to change the title tag based on url parameters or sql query...

As i may have state before... 'speaking' parameters may be of help with google indexing...

So i made a typoscript extension for the page with this code:

config.noPageTitle = 2

page.headerData.20 = TEXT
page.headerData.20.value = Felix - Il portale del gatto: disponibile - foto -
page.headerData.20.wrap = <title>|
page.headerData.21 = TEXT
page.headerData.21.data = global : HTTP_GET_VARS |ALR
page.headerData.21.noTrimWrap=|   ||
page.headerData.23 = TEXT
page.headerData.23.data = global : HTTP_GET_VARS |GATTO
page.headerData.23.noTrimWrap=|   ||
page.headerData.24 = TEXT

page.headerData.50.value = </title>


page.headerData.22 = CONTENT
page.headerData.22{
  table=fxbreeder
   
  select{
    selectFields=lrazz,uid
    andWhere.data = global:HTTP_GET_VARS|ALZ
    andWhere.wrap = uid='|'
   
  }
  renderObj=COA
  renderObj{
    5=TEXT
    5{
            field=lrazz
    }   
  }
}
 First line config.noPageTitle = 2 is very important since delete the basic title tag for the page and open the opportuinity  of write the title tag through the typoscript system.

But... i noticed though google webmaster tools that when the title becomes too long the </title> was not written in the page.  The title tag become oversized in the whole page and i get this behavior:

the page http://www.felixweb.it/public/index.php?id=266&FID=1035&ALZ=130&GATTO=Torakiki%20Love%20of%20my%20Life%20%20black%20silver%20mackerel%20&%20white&L=0

got the title trunked title tag:

Felix - Il portale del gatto: disponibile - foto - Torakiki Love of my Life black silver mackerel <meta name ....

You can see the next tag in the header appearing in the title tag!

So i decided to change method:

You still need the first row with config.noPageTitle = 2 in order to get your php lumo record to work.

This is the part of the script for the new method:

<?php
$fid = $_GET['FID'];
$gatto = $_GET['GATTO'];
$alr= $_GET['ALR'];
$GLOBALS ['TSFE'] -> additionalHeaderData ['100 '] ='<title>Felix - Il portale del gatto: foto '.$gatto.'</title>';
In this case the script goes on and render the rest of the page with a query from the FID url paramether, but this is old story!

2 commenti: