Dynamic Title and Meta Tags
PHP Code
+ 2 likes
Please Register to submit score.
| Average Score | 4.0 (of 2 scores) |
| Date Added | Dec 10, 2007 |
| Last Updated | Dec 10, 2007 |
| Tags | dynamic keywords meta php tags title |
Introduction
page_name.html|page title|meta tags|meta description
page_name2.html|page title2|meta tags for page 2|meta description for page 2
To use the code either save it at the top of your header file or save it as get_meta.php and add this line of code to your header:
| Code: |
| <?php include('get_meta.php'); ?> |
You can reference the $title, $meta_keywords and $meta_description variables in your header like this:
| Code: |
| <title><?php print $title; ?></title> <meta name="keywords" content="<?php print $meta_keywords; ?>"> |
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Dec 10, 2007 5:36 am
Posted on Dec 10, 2007 5:36 am
simple, yet nice way to accomplish something that could be respectivly more complex
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Dec 10, 2007 11:32 am
Posted on Dec 10, 2007 11:32 am
nice, i like this one
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Dec 18, 2007 6:24 pm
Posted on Dec 18, 2007 6:24 pm
I don't know, I'm new here but this snippet seems pretty worthless except for a few special cases. I would like to say this site is a great concept and pretty good implementation though. I would like to see an easy way to see most-used and highest-rated snippets in any language, though!
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Jan 8, 2008 7:10 pm
Posted on Jan 8, 2008 7:10 pm
Thanks for the feedback alan. This snippet was a request by a friend to be used as a learning tool, but some others who are new to site building may find it useful.
You can see the highest rated snippets in every category by choosing to sort by score. You can also see the highest rated snippets for any search or tag by using the same sort. We'll also be implementing a newer way to find more current, highly rated snippets in the near future.
You can see the highest rated snippets in every category by choosing to sort by score. You can also see the highest rated snippets for any search or tag by using the same sort. We'll also be implementing a newer way to find more current, highly rated snippets in the near future.
PHP Snippet:
Dynamic Title and Meta Tags
Posted on May 14, 2008 2:02 pm
Posted on May 14, 2008 2:02 pm
Sorry to dig up an old post however this is I am sure what I have been looking for my site, collectable fish dot com. Feel free alanh to contradict me with an alternative :-)
However, I am pretty dim when it comes to these techie things and wonder if anyone can walk me thru dropping in the code on my site?
Thnx
However, I am pretty dim when it comes to these techie things and wonder if anyone can walk me thru dropping in the code on my site?
Thnx
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Oct 10, 2008 10:09 pm
Posted on Oct 10, 2008 10:09 pm
Dynamic titles are a good idea. I have posted a different solution for dynamic meta tags and title tag for php websites on TechTipStation.com that allows you to define the meta tags on each page instead of in a mapping file like the example above. It is also designed to automatically generate the text for the TITLE tag based on the text of the H1 tag in your individual pages.
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Nov 5, 2008 10:34 pm
Posted on Nov 5, 2008 10:34 pm
Hi! I am confused what does where?
#1 Are these 2 pieces of code in header file?
<?php include('get_meta.php'); ?>
<title><?php print $title; ?></title>
<meta name="keywords" content="<?php print $meta_keywords; ?>">
#2 and if so where should this be pasted ios it also in header file???
<?php
$database = 'meta_tags.txt';
$meta_db = fopen($database, 'r');
$page = $_SERVER['SCRIPT_NAME'];
$page = substr($page, 1);
while($data = fgetcsv($meta_db, 9000, '|'))
{
if($data[0] == $page)
{
$title = $data[1];
$meta_keywords = $data[2];
$meta_description = $data[3];
}
}
?>
#3 do I have to alter any of the code ?
It sounds simple I looked at the dynamic meta tags and had a brain freeze!
#1 Are these 2 pieces of code in header file?
<?php include('get_meta.php'); ?>
<title><?php print $title; ?></title>
<meta name="keywords" content="<?php print $meta_keywords; ?>">
#2 and if so where should this be pasted ios it also in header file???
<?php
$database = 'meta_tags.txt';
$meta_db = fopen($database, 'r');
$page = $_SERVER['SCRIPT_NAME'];
$page = substr($page, 1);
while($data = fgetcsv($meta_db, 9000, '|'))
{
if($data[0] == $page)
{
$title = $data[1];
$meta_keywords = $data[2];
$meta_description = $data[3];
}
}
?>
#3 do I have to alter any of the code ?
It sounds simple I looked at the dynamic meta tags and had a brain freeze!
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Nov 6, 2008 1:24 pm
Posted on Nov 6, 2008 1:24 pm
#1 - Yes that goes in your header file. #2 - this code goes in get_meta.php. You just need to be sure to create meta_tags.txt as specified in the Introduction.
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Dec 21, 2008 4:25 am
Posted on Dec 21, 2008 4:25 am
Hey, thanks so much for this snippet. I wanted to know if there was a way to add a default variable so that if a user goes to a page that isn't included in the meta_tags.txt, he won't get an error.
Thanks!
Thanks!
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Dec 21, 2008 10:24 am
Posted on Dec 21, 2008 10:24 am
Sure, just set the $title, $meta_keywords and $meta_description variables before the while loop to their default values. They'll remain the default values if no matching row was found in the text file.
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Dec 22, 2008 12:06 am
Posted on Dec 22, 2008 12:06 am
Great little script.
I have a problem however in implementing it within a .php file that subsequently gets modded via .htaccess to a .html file - the $title tag is blank in the source.
I have done everything as above, and referenced the .html version of the page in the meta_tags.txt
It works okay if in a standard php or html page and is just what I need... if only I could get the above happening!
I have a problem however in implementing it within a .php file that subsequently gets modded via .htaccess to a .html file - the $title tag is blank in the source.
I have done everything as above, and referenced the .html version of the page in the meta_tags.txt
It works okay if in a standard php or html page and is just what I need... if only I could get the above happening!
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Dec 22, 2008 11:58 am
Posted on Dec 22, 2008 11:58 am
glenster, maybe try "echo $page;" just before the while loop to see what your $_SERVER is returning as the script name. Then make sure that matches what you've got in your meta_tags.txt
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Dec 22, 2008 5:23 pm
Posted on Dec 22, 2008 5:23 pm
Hmm.. ok I did that and it seems to be referencing the original .php template file that generates multiple .php? pages for us (they are search listings), and then we mod rewrite those .php? pages into .html such as search1.html, search2.html etc
I can't seem to reference search1.html etc in meta_tags.txt, as $_SERVER wants to refer back to the original .php template file.
Is there anything you know of that can be added to your code to force get_meta.php to refer to the finished mod'ed pages instead?
I was so near yet am so far from the perfect solution! :(
I can't seem to reference search1.html etc in meta_tags.txt, as $_SERVER wants to refer back to the original .php template file.
Is there anything you know of that can be added to your code to force get_meta.php to refer to the finished mod'ed pages instead?
I was so near yet am so far from the perfect solution! :(
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Dec 24, 2008 1:41 pm
Posted on Dec 24, 2008 1:41 pm
So maybe you can just set $page to your search query and use that rather than the script name? Then just reference each search query in your meta_tags.txt file. Lots of ways to go about this.
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Dec 25, 2008 10:27 pm
Posted on Dec 25, 2008 10:27 pm
Thanks for the suggestion Hawkee
To get mod rewrited pages working with Hawkee's script, simply replace
$page = $_SERVER['SCRIPT_NAME'];
with
$page = $_SERVER['REQUEST_URI'];
Now, my next step is to find a way to streamline the meta_tags.txt file. We have 1000's of mod rewrited pages on my site, and I am trying to figure out a way to only do say, 10 standard page titles with unique variables that can be populated throughout the 1000's of pages.
To get mod rewrited pages working with Hawkee's script, simply replace
$page = $_SERVER['SCRIPT_NAME'];
with
$page = $_SERVER['REQUEST_URI'];
Now, my next step is to find a way to streamline the meta_tags.txt file. We have 1000's of mod rewrited pages on my site, and I am trying to figure out a way to only do say, 10 standard page titles with unique variables that can be populated throughout the 1000's of pages.
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Feb 15, 2009 11:18 am
Posted on Feb 15, 2009 11:18 am
I'm having a problem, i'm updateing my site http://www.Rose-Learning.com to use this and I have the .txt file, the get_meta.php, and the code in my header but it isn't reading any of the database code. I am using godaddy for my hosting I dunno if that matters. Can someone please help I need my meta tags to be different in each of my pages and I really need this code to work for my business.
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Feb 15, 2009 2:32 pm
Posted on Feb 15, 2009 2:32 pm
juado, maybe try some debugging code to see what's going wrong. Before the while statement add this:
echo $page;
Then reload your page and see what the value is. That's what you'll need to have in your .txt file in order for it to match up.
echo $page;
Then reload your page and see what the value is. That's what you'll need to have in your .txt file in order for it to match up.
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Feb 15, 2009 7:02 pm
Posted on Feb 15, 2009 7:02 pm
ok cool I did that and got index.php in my source file then i tried to load all my various pages and get the same output. I think that's bad. My txt file looks like
index.php|Home|meta tags|home discription
p=services|Services|meta tags for page 2|services discription
tutors.html|Tutor|meta tags for page 2|tutor description
I used a variety of page names to see which would work. I can't seem to get any of them to. I get no title or keywords to show up! Could you help me more with the debugging.
Another piece of code which i'm working with also to try to get something to work for my tags. This is in a file called load.php
<?php
$page = $_GET["p=home"];
// Default content if no page is selected
if (empty($page)) {
$metas = "Power, blah, blah,...";
$title = "home";
$description = "home description";
}
// One page
if ($page == "p=services") {
$metas = "aspdapksd";
$title = "homethml";
$description = "hoem desppsd";
}
// Another page...
if ($page == "p=tutors") {
$metas = "Powsdader, blah, blah,...";
$title = "tutorssss";
$description = "I AM A TUTOR!";
}
?>
I was also tring this bit of code and to see if this would be better b/c i just have to echo in the variables in my index.php file.
index.php|Home|meta tags|home discription
p=services|Services|meta tags for page 2|services discription
tutors.html|Tutor|meta tags for page 2|tutor description
I used a variety of page names to see which would work. I can't seem to get any of them to. I get no title or keywords to show up! Could you help me more with the debugging.
Another piece of code which i'm working with also to try to get something to work for my tags. This is in a file called load.php
<?php
$page = $_GET["p=home"];
// Default content if no page is selected
if (empty($page)) {
$metas = "Power, blah, blah,...";
$title = "home";
$description = "home description";
}
// One page
if ($page == "p=services") {
$metas = "aspdapksd";
$title = "homethml";
$description = "hoem desppsd";
}
// Another page...
if ($page == "p=tutors") {
$metas = "Powsdader, blah, blah,...";
$title = "tutorssss";
$description = "I AM A TUTOR!";
}
?>
I was also tring this bit of code and to see if this would be better b/c i just have to echo in the variables in my index.php file.
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Feb 15, 2009 7:02 pm
Posted on Feb 15, 2009 7:02 pm
Then just put into index.php
<?php include 'load.php'; ?>
<meta name="keywords" content="<?php echo $metas; ?>" />
<meta name="description" content="<?php echo $description; ?>" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $title; ?></title>
<?php include 'load.php'; ?>
<meta name="keywords" content="<?php echo $metas; ?>" />
<meta name="description" content="<?php echo $description; ?>" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $title; ?></title>
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Feb 15, 2009 8:22 pm
Posted on Feb 15, 2009 8:22 pm
juado, if you have a $p variable already maybe try using that instead of $page. So before the while loop just do $page = $p; and use your p variables in the meta txt file.
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Feb 16, 2009 6:42 pm
Posted on Feb 16, 2009 6:42 pm
Thanks so much it works!!!
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Feb 16, 2009 6:45 pm
Posted on Feb 16, 2009 6:45 pm
juado, great!
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Feb 16, 2009 7:12 pm
Posted on Feb 16, 2009 7:12 pm
Does reciprocal links help in google ranking or just inbound links, or they don't help as much?
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Feb 16, 2009 8:05 pm
Posted on Feb 16, 2009 8:05 pm
Mostly inbound links but it depends on how strong the reciprocal links are. As a general rule if the link provides traffic directly it may help with Google.
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Mar 4, 2009 6:22 am
Posted on Mar 4, 2009 6:22 am
I tried to put the script in my site, but the title says Array, someone help me please?
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Mar 4, 2009 9:00 am
Posted on Mar 4, 2009 9:00 am
the only thing I changed in the script is $database by $database1
I'm turning and I can not find the error.
Alguen please help me.
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Mar 4, 2009 10:53 am
Posted on Mar 4, 2009 10:53 am
I have achieved, was the route of the html in the txt.
Thanks, very good script, you're a genius
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Mar 10, 2009 11:25 am
Posted on Mar 10, 2009 11:25 am
Hi,
I love this script well done, nice and simple,
Until I get to dynamic urls like:
product.php?catid=1&subcatid=1&productId=5
I can't work out how to link the meta to the 'productId'?
Any pointers please?
Many thanks.
I love this script well done, nice and simple,
Until I get to dynamic urls like:
product.php?catid=1&subcatid=1&productId=5
I can't work out how to link the meta to the 'productId'?
Any pointers please?
Many thanks.
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Mar 10, 2009 5:11 pm
Posted on Mar 10, 2009 5:11 pm
smitheroo, you either have to introduce a new variable or use one of the variables you've already got. For example you could use catid and if $page == 'product.php' then $page = $catid. Then you can use the catid as the key in your txt database file.
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Mar 11, 2009 4:41 am
Posted on Mar 11, 2009 4:41 am
Many thanks for the quick reply.
Does this go before the while statement?
like this?
if($page == 'product.php')
{$page = $productId;}
I Appreciate your help.
Ian
Does this go before the while statement?
like this?
if($page == 'product.php')
{$page = $productId;}
I Appreciate your help.
Ian
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Mar 11, 2009 12:59 pm
Posted on Mar 11, 2009 12:59 pm
Yes, before the while statement.
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Mar 12, 2009 5:30 am
Posted on Mar 12, 2009 5:30 am
Sorry to pester but this isn't working for me. Can you look at my code ingredients below please? Thanks very much.
Here's a line from my 'meta_tags.txt' file:
'productId=69|Alarm Clock (LED Colour Changing)|meta tags|meta description'
Here's my 'get_meta.php' code:
<?php
$database = 'meta_tags.txt';
$meta_db = fopen($database, 'r');
$page = $_SERVER['SCRIPT_NAME'];
$page = substr($page, 1);
if($page == 'product2.php')
{$page = $productId;}
while($data = fgetcsv($meta_db, 9000, '|'))
{
if($data[0] == $page)
{
$title = $data[1];
$meta_keywords = $data[2];
$meta_description = $data[3];
}
}
?>
Here's the url, I got to to check to see if it works:
http://www.altereglow.co.uk/product2.php?productId=69
Here's a line from my 'meta_tags.txt' file:
'productId=69|Alarm Clock (LED Colour Changing)|meta tags|meta description'
Here's my 'get_meta.php' code:
<?php
$database = 'meta_tags.txt';
$meta_db = fopen($database, 'r');
$page = $_SERVER['SCRIPT_NAME'];
$page = substr($page, 1);
if($page == 'product2.php')
{$page = $productId;}
while($data = fgetcsv($meta_db, 9000, '|'))
{
if($data[0] == $page)
{
$title = $data[1];
$meta_keywords = $data[2];
$meta_description = $data[3];
}
}
?>
Here's the url, I got to to check to see if it works:
http://www.altereglow.co.uk/product2.php?productId=69
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Mar 12, 2009 10:50 am
Posted on Mar 12, 2009 10:50 am
smitheroo, your $productid variable should only contain the value that you set for it. In this case "69". So your meta_tags.txt should only have "69" as the key, not "productid=69"
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Mar 13, 2009 7:34 am
Posted on Mar 13, 2009 7:34 am
Hawkee thanks for your help on this,
Thanks for the heads up on the productId in the database file.
Well, it all works until I put the if statement above the while statement.
if($page == 'product2.php'){
$page = $productId;
}
Can you spot any typos there?
Sorry to be so lame on my php coding.
If it helps, here's the whole code from 'get_meta.php'
<?php
$database = 'meta_tags.txt';
$meta_db = fopen($database, 'r');
$page = $_SERVER['SCRIPT_NAME'];
$page = substr($page, 1);
if($page == 'product2.php'){
$page = $productId;
}
while($data = fgetcsv($meta_db, 9000, '|'))
{
if($data[0] == $page)
{
$title = $data[1];
$meta_keywords = $data[2];
$meta_description = $data[3];
}
}
?>
Thanks for the heads up on the productId in the database file.
Well, it all works until I put the if statement above the while statement.
if($page == 'product2.php'){
$page = $productId;
}
Can you spot any typos there?
Sorry to be so lame on my php coding.
If it helps, here's the whole code from 'get_meta.php'
<?php
$database = 'meta_tags.txt';
$meta_db = fopen($database, 'r');
$page = $_SERVER['SCRIPT_NAME'];
$page = substr($page, 1);
if($page == 'product2.php'){
$page = $productId;
}
while($data = fgetcsv($meta_db, 9000, '|'))
{
if($data[0] == $page)
{
$title = $data[1];
$meta_keywords = $data[2];
$meta_description = $data[3];
}
}
?>
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Mar 13, 2009 1:35 pm
Posted on Mar 13, 2009 1:35 pm
Maybe you should check the value of $page before you compare it to "product2.php" just to make sure it's got the right value. It's always good to debug your code by echo'ing the values of your variables. Just do "echo $page;" above your if-statement to see what the value is.
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Mar 16, 2009 5:34 am
Posted on Mar 16, 2009 5:34 am
Hi Hawkee,
'echo $page' returns the correct page 'product2.php'
(should it return the page name with the product id too?)
If I place 'product2.php' in the txt database file, it works.
I'm wondering whether there's a conflict with other php code in the same page.
Thanks for your efforts
'echo $page' returns the correct page 'product2.php'
(should it return the page name with the product id too?)
If I place 'product2.php' in the txt database file, it works.
I'm wondering whether there's a conflict with other php code in the same page.
Thanks for your efforts
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Mar 16, 2009 12:20 pm
Posted on Mar 16, 2009 12:20 pm
The only thing I can think now is maybe $productid isn't defined at this point. Make sure you've got $productid = $_GET[productid]; above the point you're using that variable.
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Mar 17, 2009 6:01 am
Posted on Mar 17, 2009 6:01 am
Now then, as Larry David would say, I'm feeling pret-ty, pret-ty good.
God bless America.
Here endeth the lesson. Thanks for your time Hawkee!
God bless America.
Here endeth the lesson. Thanks for your time Hawkee!
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Mar 28, 2009 4:40 pm
Posted on Mar 28, 2009 4:40 pm
Hi,
Super script :)
I've got it on a php framework site with mod rewrite - index.php is the master template pulling in page content files; about-us.php, info.php etc.
I'm using the
$page = $_SERVER['REQUEST_URI'];
code which works great - meta info for all my pages.. except the homepage.
Any suggestions what I'd need to do to include it?
The homepage=the domain name therefore
echo $page;
doesn't return any value for the homepage - only the rest of the pages in the site.
Any help/pointers most appreciated.
E
Super script :)
I've got it on a php framework site with mod rewrite - index.php is the master template pulling in page content files; about-us.php, info.php etc.
I'm using the
$page = $_SERVER['REQUEST_URI'];
code which works great - meta info for all my pages.. except the homepage.
Any suggestions what I'd need to do to include it?
The homepage=the domain name therefore
echo $page;
doesn't return any value for the homepage - only the rest of the pages in the site.
Any help/pointers most appreciated.
E
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Mar 28, 2009 4:46 pm
Posted on Mar 28, 2009 4:46 pm
Maybe do something like:
Then just use "home" in your data file.
| Code: |
| if(!$page) { $page = 'home'; } |
Then just use "home" in your data file.
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Mar 30, 2009 3:18 am
Posted on Mar 30, 2009 3:18 am
Ah, of course :)
Thank you.
E
Thank you.
E
PHP Snippet:
Dynamic Title and Meta Tags
Posted on May 8, 2009 10:12 am
Posted on May 8, 2009 10:12 am
Would anyone want to quote £$ to implement this on a site of mine?
If so ping me an email howie100 at gmail dot com
Thanks
HJ
If so ping me an email howie100 at gmail dot com
Thanks
HJ
PHP Snippet:
Dynamic Title and Meta Tags
Posted on May 22, 2009 5:08 am
Posted on May 22, 2009 5:08 am
hmmmmmmmmmm. no meta daTa displYED AT ALL ???
doesnt like :: fgetcsv stops right there. I suppose I coulg have just changed all the meta tag data by hand by now.... but really wanted this to work. dont now what to replace that with.... tried a few things...... nothin works.
echo $page;
while($data = fgetcsv($meta_db, 9000, '|'))
{
if($data[0] == $page)
{
$title = $data[1];
$meta_keywords = $data[2];
$meta_description = $data[3];
}
}
my phpwrapper looks like this /////
#!/bin/sh
#
# A simple wrapper for PHP.
PHPRC=/vservers/magicwebs/etc
export PHPRC
PHP_FCGI_CHILDREN=2
export PHP_FCGI_CHILDREN
exec /opt/php/bin/php
meta_tags.txt get_meta.php are both in the root directory as are all the php pages I was trying to use this on... no luck. have the wrong address there. php5 is on the server. totally thrown off by this "" fgetcsv "" file get what ? that doesn't exist on my server...... the page displays...... just displays the echo for the line it chokes on at the top.
meta_tags.txt is set up like //
index.php|the homepage ~ home|keyword1, keyword2, etc, etc| A small Connecticut company.
interact.php|contact page ~ contact|keyword1, keyword2, etc, etc| Contact a small Connecticut company.
I believe that is how the php code reads the 3 entities separated by | ... but nothin is outputted , just the html tags and quotes... nothin in between. so the path to the the string data location is not correct. funny how there were no posts about that...... it just worked on the same path for everyone?
if u see something Idon't........ but I doubt anyone will even see this post the thread is so old.
tia
doesnt like :: fgetcsv stops right there. I suppose I coulg have just changed all the meta tag data by hand by now.... but really wanted this to work. dont now what to replace that with.... tried a few things...... nothin works.
echo $page;
while($data = fgetcsv($meta_db, 9000, '|'))
{
if($data[0] == $page)
{
$title = $data[1];
$meta_keywords = $data[2];
$meta_description = $data[3];
}
}
my phpwrapper looks like this /////
#!/bin/sh
#
# A simple wrapper for PHP.
PHPRC=/vservers/magicwebs/etc
export PHPRC
PHP_FCGI_CHILDREN=2
export PHP_FCGI_CHILDREN
exec /opt/php/bin/php
meta_tags.txt get_meta.php are both in the root directory as are all the php pages I was trying to use this on... no luck. have the wrong address there. php5 is on the server. totally thrown off by this "" fgetcsv "" file get what ? that doesn't exist on my server...... the page displays...... just displays the echo for the line it chokes on at the top.
meta_tags.txt is set up like //
index.php|the homepage ~ home|keyword1, keyword2, etc, etc| A small Connecticut company.
interact.php|contact page ~ contact|keyword1, keyword2, etc, etc| Contact a small Connecticut company.
I believe that is how the php code reads the 3 entities separated by | ... but nothin is outputted , just the html tags and quotes... nothin in between. so the path to the the string data location is not correct. funny how there were no posts about that...... it just worked on the same path for everyone?
if u see something Idon't........ but I doubt anyone will even see this post the thread is so old.
tia
PHP Snippet:
Dynamic Title and Meta Tags
Posted on May 22, 2009 5:59 am
Posted on May 22, 2009 5:59 am
works........... server doesnt have the script name variable so needed to use $_SERVER["PHP_SELF"] instead. anyway. disregard my last post.
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Jun 12, 2009 11:01 am
Posted on Jun 12, 2009 11:01 am
It was a great code. I got it within few hours up running.
The question i want to ask is does dynamic meta tags helps in seo i.e does google see the page an user sees nad not the dynamic content. since my site has a poor ranking i am more concern to bring it up using good techniques can anyone help
The question i want to ask is does dynamic meta tags helps in seo i.e does google see the page an user sees nad not the dynamic content. since my site has a poor ranking i am more concern to bring it up using good techniques can anyone help
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Jun 12, 2009 4:52 pm
Posted on Jun 12, 2009 4:52 pm
This is meant to make managing meta tags easier from a webmaster standpoint. The end result is exactly the same as far as Google as concerned. Whether you store them in a database or not they'll always end up in the same place on the page. The key to SEO is just getting the authority so Google pays attention to your keywords.
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Jun 16, 2009 5:08 am
Posted on Jun 16, 2009 5:08 am
Thanks hawkee for the great code and help. Can you help me in one more thing my site has google ranking of 3. The content in the website is little bit same as the other people have since the data are given by suppliers. The external links to the website is only few but all the external website have a ranking of 4 to 3. I need to improve the backlinks to the website and i need to improve my ranking give me some crystal tips. I have done all ways of optimization that are possible for the site like adding header tags,title tags...etc even the page exists in google but it exists in the 3 or 4 page of google this brings my sales down.
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Jun 16, 2009 11:24 pm
Posted on Jun 16, 2009 11:24 pm
Best advice I can give is to make a really good site with information nobody can find anywhere else so people are inclined to share it naturally through networks like Twitter and Facebook.
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Jun 17, 2009 11:05 am
Posted on Jun 17, 2009 11:05 am
Thanks hawkee. how many record can we have in the meta_tags.txt file since i have nearly 100 brands to be included.
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Jun 17, 2009 4:07 pm
Posted on Jun 17, 2009 4:07 pm
As many as you'd like, but eventually you probably want to move to a database (mySQL) structure. Text files aren't meant to be used for large scale data projects.
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Jul 24, 2009 8:44 am
Posted on Jul 24, 2009 8:44 am
Hi Hawkee,
Great Stuff, got it all working, just one thing. if i go to my site domain.com/index.php it brings up the description etc.. great) but if i just go to domain.com it doesnt recognize anything from the .txt file, how do i make the domain without the index.php on the end bring up the descriptions etc.. Thank inadvance.
Great Stuff, got it all working, just one thing. if i go to my site domain.com/index.php it brings up the description etc.. great) but if i just go to domain.com it doesnt recognize anything from the .txt file, how do i make the domain without the index.php on the end bring up the descriptions etc.. Thank inadvance.
PHP Snippet:
Dynamic Title and Meta Tags
Posted on Jul 24, 2009 12:51 pm
Posted on Jul 24, 2009 12:51 pm
mobimad, before the while loop you can set a default $page value if none is set. For example:
| Code: |
| if(!$page) $page = 'index.php'; |













