Author Topic: Custom metatags  (Read 637 times)

0 Members and 1 Guest are viewing this topic.

Offline hilflo

  • Full phpd Member
  • ***
  • Posts: 98
  • Karma: 2
  • Sorry for my bad english
    • View Profile
    • Les félés
Custom metatags
« on: November 26, 2009, 07:53:40 AM »
Hi all, it's my first post and I use it to share with us a little addon to the community. Sorry if my english is not really good, I'm french and all knows that french people are not specialist to speak foreign language !!!

With this little addon, you will have "dynamic" metatags.

Open header.php and add at the end of the file :

Code: [Select]
$idc=$_GET['id'];
if(isset($idc))
{
$result = mysql_query("SELECT * FROM pp_files WHERE id=$idc") or die(mysql_error()); 
$row = mysql_fetch_assoc($result);
$smarty->assign('title', $row['name']);
$smarty->assign('desc', $row['description']);
}
else
{
$smarty->assign('desc', 'DESCRIPTION OF YOUR SITE');
$smarty->assign('title', 'YOUR SLOGAN');
}

Open header.tpl:
Replace
Code: [Select]
<title>{$config_name|default:"PHP Director"}</title>
with
Code: [Select]
<title>{$config_name|default:"PHP Director"} - {$title}</title>
If you have no meta description add
Code: [Select]
<meta name="description" content="{$desc}" />
Now when you go to a video page, you have the title of your website with the name of the video and the meta description is the description of the video.
If you aren't on a video page, it's your general metatags which is used.

Offline FireDart

  • Project Leader
  • Pro Member
  • *****
  • Posts: 406
  • Karma: 4
    • View Profile
    • FireDart
Re: Custom metatags
« Reply #1 on: November 26, 2009, 04:22:04 PM »
Cool, I was working on a new template that would involve tags just like this.

Thanks for saving me time!

Offline xsnoboard

  • phpd Basic Member
  • **
  • Posts: 39
  • Karma: 0
    • View Profile
    • My Vid Space
Re: Custom metatags
« Reply #2 on: November 26, 2009, 05:54:11 PM »
Awesome Thanks! Works great!