Forum Moderators: coopster

Message Too Old, No Replies

Automated Meta Tags.

         

Tomness

10:00 am on Jul 16, 2005 (gmt 0)

10+ Year Member



Hey, it's me again,

My website uses php to call pages,

index.php?get=page.html

So this means everything is called to one index page, so the index page is the only page that's setup to have a full set of HTML tags, because if the pages that were called to the body had them, this might cause problems for certain users.

However, this means I only have one page with meta tags in it, which I feel my dramaticaly effect my SEO.

Is there any way I can automate these so that they change depending on the page called?

Also, could someone tell me the correct term for calling pages using php, what is that sort of script called.

maxi million

2:59 pm on Jul 16, 2005 (gmt 0)

10+ Year Member




Also, could someone tell me the correct term for calling pages using php, what is that sort of script called.

You mean include()?

For the first part of your problem, your work would be really easy if you entered the meta tags corresponding to your pages in a database.

exaple:
table 'metatags' could have these fields: id¦pagename¦title¦description¦keywords
and entries:
1¦page1.html¦page one¦my first page¦first,page
2¦page2.html¦page two¦my second page¦second,page

in index.php right on top you could have the call to db to get these tags:
<?php
$conn = mysql_connect("localhost", "name", "pass") or die(mysql_error());
mysql_select_db('databaseone', $conn) or die(mysql_error());
$page = $_GET['get'];
$query = mysql_query("SELECT * FROM metatags WHERE pagename=$page");
$metatags = mysql_fetch_array($query);
?>
and then,
<html>
<head>
<title><?php echo $metatags['title'];?></title>
<meta name="description" content="<?php echo $metatags['description'];?>">
<meta name="keywords" content="<?php echo $metatags['keywords'];?>">
</head>
<body>
<?php
include($page);
?>
</body>
</html>

this is ofcourse is very simplified way of doing it and youll need to customize the stuff to meet your goal. and youll need some error checking code there also, just in case there is nothing for '?get' or if the page mentioned just doesnt exist. in short you have to consider all security implications, as its really simple to manipulate the url.

hope this works for you
:)

ergophobe

3:18 pm on Jul 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




Is there any way I can automate these so that they change depending on the page called?

If the script is put together such that it gathers information first, then processes it, then outputs it, you should be able to set a variable to hold the meta info and then output it.

If the script just echos out information as it is processing, that's going to be harder.

In other words, somewhere upstream of the any output for the index page, you need to set the meta tag based on the page in question.


Also, could someone tell me the correct term for calling pages using php, what is that sort of script called.

I'm not sure what you mean? You mean this method of running everything through the index page and calling the specific content via some other parameter in the URL? I call it "using a gatekeeper script" but that's just my terminology. Never heard it anywhere else before, so I'm not sure anyone else would know what you meant.