You are here: Re: How 2 include meta tags? « PHP Language « IT news, forums, messages
Re: How 2 include meta tags?

Posted by shimmyshack on 05/04/07 09:10

On May 4, 10:08 am, shimmyshack <matt.fa...@gmail.com> wrote:
> On May 4, 8:57 am, tochiro <nos...@nospam.com> wrote:
>
> > Hello,
>
> > I have a small website and I use the include function for the top head
> > section of each page. This is convenient but all the pages have the
> > same meta tags as a result.
>
> > I would like to have different meta tags for each page. What it the
> > most effective method to do that without access to a data base?
>
> > I am a beginner.
>
> > Thank you for your help.
>
> you do have access to sqllite probably, but anyway
> inside your header you might want to have an include('meta_tags.php');
> statement.
> this is a script that detects the page its on using
> $_SERVER['REQUEST_URI'] or if each page is a query string, ?
> page=page123 then it should detect the QS and find the page that way.
> then you can have something like this:
>
> ----------------
> <?php
> $title = 'Website - ';
> $descriptions = '';
> $author = '';
> #other perpage metatags go here
>
> switch ($page)
> {
> case 'sales':
> $keywords = 'sales, buy stuff';
> $description = 'Our Friendly Sales Page';
> $title .= 'Sales';
> break;
> case 'contact':
> $keywords = 'contact us, email us, contact, get in touch';
> $description = 'We are always happy to hear from you';
> $title .= 'Contact Us';
> $author = 'tochiro';
> break;
> .
> .
> .
> $title = ($title=='Website - ') ? $title.'The Place To Be' :
> ucwords($title);
> $keywords = ($keywords=='') ? 'My Website, great website, buy stuff,
> blah blah' : $keywords;
>
> ?>
> <title><?php echo $title; ?></title>
> <meta name="keywords" content="<?php echo $keywords; ?>" />
> <meta name="description" content="<?php echo $description; ?>" />
> <?php if($author!='') echo "\n".'<meta name="author" content="'.
> $author.'" />'."\n"; ?>
>
> -----------------
>
> its cheap and cheerful, but hey

and of course dont forget to set a default, and close the switch
statement

default :
$keywords = 'the start of it all, homepage blah';
$description = 'great website, etc, blah';
$title = 'Welcome to our website';
break;
}

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация