You are here:  » Change title,description and keywords

Support Forum



Change title,description and keywords

Submitted by ser_seven on Mon, 2006-08-28 13:57 in

Hello

I want add in the header.php meta tag description and meta tag keywords !!
But i want change meta tag :title,description and keywords in base page URL !!

Similar talk in this discussion http://www.pricetapestry.com/node/409 when through script change.

I wanted however to maintain the title, the description and the keywords of this page products.php and reviews.php

It's possible ?

Very Tnks

Submitted by support on Mon, 2006-08-28 15:30

Hello Ser,

The meta tags keywords and description are currently set by loading an array on the following lines:

products.php Line 52:

<?php
      $header
["meta"]["description"] = translate("Price search results for")." ".htmlentities($q,ENT_QUOTES,$config_charset);
      
$header["meta"]["keywords"] = htmlentities($q,ENT_QUOTES,$config_charset);
?>

reviews.php Line 66:

<?php
      $header
["meta"]["description"] = translate("Product reviews for")." ".htmlentities($q,ENT_QUOTES,$config_charset);
      
$header["meta"]["keywords"] = htmlentities($q,ENT_QUOTES,$config_charset);
?>

You can of course set the values of $header["meta"]["description"] and $header["meta"]["keywords"] to be whatever you like, including fixed values if that is what you want to do.

I think I can help more if you give example of what you want in the meta tags.....

Cheers,
David.

Submitted by ser_seven on Mon, 2006-08-28 16:14

products.php and reviews.phps are all right as I am currently.

I want add meta tag description and keywords for the other pages.

Example. I create the page /pc-desktop.qhtml (without .htaccess is /search=?pc-desktop/ ) and i want in this page insert meta tag description and keywords different another page...

example with a formula...

if (/pc-descktop.qhtml) [header(description)=Best Price for PC Desktop] & [header(keywords)=Pc, Descktop, Price, Hardware]

if (/nokia-telephone.qhtml) [header(description)=Nokia Connercted People] & [header(keywords)=Nokia,Telephone,Number,Phone]

.....

meta tag and description insert manually.

Tnk you very much

Submitted by support on Mon, 2006-08-28 17:05

Hello Ser,

The meta description tag can be set easily automatically. In search.php, find this line (131 in the distribution):

    $header["title"] = $q;

To set the description header, add this on the next line:

    $header["title"] = $q;
    $header["meta"]["description"] = "Best price for ".htmlentities($q,ENT_QUOTES,$config_charset);

The keywords will be more difficult because there is no data to select them from so you will have to do it manually. One way to do it would be like this:

    $header["title"] = $q;
    $header["meta"]["description"] = "Best price for ".htmlentities($q,ENT_QUOTES,$config_charset);
    // create an array of keyword tags for each known xxxx.qhtml
    $keywords["PC Desktop"] = "Pc, Descktop, Price, Hardware";
    $keywords["Nokia Telephone] = "Nokia, Telephone, Number, Phone";
    // then set the keywords tag from the array
    $header["meta"]["keywords"] = $keywords[$q]

Hope this helps!
David.

Submitted by ser_seven on Mon, 2006-08-28 21:51

Hi David..

Submitted by support on Tue, 2006-08-29 07:01

Hello Ser,

Yes - that should be the complete code to do what you want; although I noticed reading your post again that you wanted to manually control the description header as well as the keywords.

You can do that using the same technique; again, add the following code into search.php:

<?php
    
// existing code on line 131:
    
$header["title"] = $q;
    
// new code:
    // create an array of description tags for each known xxxx.qhtml
    
$descriptions["PC Desktop"] = "Best price for PC Desktop";
    
$descriptions["Nokia Phone"] = "Best price for Nokia phones";
    
// then set the description meta tag from the array
    
$header["meta"]["description"] = $descriptions[$q]
    
// create an array of keyword tags for each known xxxx.qhtml
    
$keywords["PC Desktop"] = "Pc, Descktop, Price, Hardware";
    
$keywords["Nokia Phone"] = "Nokia, Telephone, Number, Phone";
    
// then set the keywords meta tag from the array
    
$header["meta"]["keywords"] = $keywords[$q]
?>

Cheers,
David.

Submitted by ser_seven on Tue, 2006-08-29 07:18

Hello David..

Submitted by support on Tue, 2006-08-29 07:24

Sorry, Ser - there are just a couple of missing semi-colon's...

    else
    {
      $banner["h2"] .= "(".translate("no results found").")";
    }
    $header["title"] = $q;
    // new code:
    // create an array of description tags for each known xxxx.qhtml
    $descriptions["Cellulare Nokia"] = "I prezzi migliori per Cellulari Nokia";
    $descriptions["Tapis Roulant"] = "I prezzi migliori per tapis roulant";
    // then set the description meta tag from the array
    $header["meta"]["description"] = $descriptions[$q];
    // create an array of keyword tags for each known xxxx.qhtml
    $keywords["cellulare nokia"] = "Cellulare Nokia, Nokia Cellulare";
    $keywords["Tapis Roulant"] = "Tapis, Roulant, Tappeti scorrevoli";
    // then set the keywords meta tag from the array
    $header["meta"]["keywords"] = $keywords[$q];
    $navigation["resultCount"] = $resultCount;

That should work...

Cheers,
David.

Submitted by ser_seven on Tue, 2006-08-29 07:46

Hello David
Good work

This is a keysensitive but it is not a problem.

Now i create a semi static page and I have succeeded to setting here meta tags.

Tnks you

Submitted by mally on Mon, 2009-04-20 19:39

Hello David

Ref the code

<?php
      $header["meta"]["description"] = translate("Price search results for")." ".htmlentities($q,ENT_QUOTES,$config_charset);
      $header["meta"]["keywords"] = htmlentities($q,ENT_QUOTES,$config_charset);
?>

Could you explain how to use remove a word in the $q so for example something like

<? { echo str_replace(' Magazine','',$q); } ?>

I would like to use that as an extra keyword

thanks MAlly

Submitted by support on Tue, 2009-04-21 07:08

Hi Mally,

Sure - you can just put the str_replace() code right inline with the $q variable, for example:

  $header["meta"]["description"] = translate("Price search results for")." ".htmlentities(str_replace(" Magazine","",$q),ENT_QUOTES,$config_charset);
  $header["meta"]["keywords"] = htmlentities(str_replace(" Magazine","",$q),ENT_QUOTES,$config_charset);

Cheers,
David.