You are here:  » meta tags


meta tags

Submitted by rolli1 on Fri, 2006-11-24 17:55 in

Hi David,
I followed the topic about metatags control. Could you please explain the use of

$header["meta"]["description"] = "Your description here";
$header["meta"]["keywords"] = "Your, Keywords, Here";

I inserted that code into the index.php before the require("includes/header.php"); code, but it does not work .

Regards

Roland

Submitted by support on Fri, 2006-11-24 19:26

Hi Roland,

The variables are picked up in includes/header.php, which scans through each item of the $header["meta"] array and creates an HTML meta tag with the key name (e.g. description or keywords) and the content.

This is done by the following line in header.php:

<?php if (isset($header["meta"])): foreach($header["meta"] as $name => $content): ?>

If you've made changes to header.php it is worth checking that this line still exists. If it's still not working; you would need to add some debug code to header.php to see why $header["meta"] is not set. You could use the print_r() function to do this; for example:

  print_r($header["meta"]);

If that doesn't produce any visible display; add the same debug code to index.php between your code and the require("html/header.php");

If you're still not getting any meta tags created (remember that you need to view the HTML source in order to see them), feel free to send me your modified index.php and header.php and i'll take a look.

Cheers,
David.

Submitted by rolli1 on Sun, 2006-11-26 10:11

Hi David,
for basic understanding: What does the code do?
I understood it this way: If I have defined description and keyword tags in the header.php the index.php will extract these tags an show it in the index page. Is this correct? Or will it automatically build meta tags?

Regards

Roland

Submitted by support on Sun, 2006-11-26 14:28

Hello Roland,

It actually works the other way round. All the main scripts in Price Tapestry include a common file called html/header.php that generates the top of the HTML. Part of this HTML that is generated is the <head> section, which is where HTML meta tags need to go.

Now, since we don't want the same meta tag content on every page; we need some mechanism to tell html/header.php what meta tags we want to be displayed (along with their content).

This is what the $header["meta"] array variable achives. Any script, before calling html/header.php can set values in that array with a key name that corresponds to the meta tag name, and a value that corresponds to the required content.

Then, html/header.php looks at $header["meta"] and, using PHPs foreach() control structure generates an HTML meta tag for each item.

This mechanism exists through the Price Tapestry script; with the main file (for example index.php) generating content in array variables that match the name of one of the HTML includes; in this case $header.

Hope this helps,
Cheers,
David.