This topic is locked

Meta tags

2/20/2009 8:02:40 AM
PHPRunner General questions
H
horsey_kim author

I want to create a meta tag database that will fill in meta tag fields based on search results for the main database.
I created a website with the main menu of the site being search urls so that it knows what information to pull up on the website. Each item in the main database have a category and that category would be the link between the search results on the page and the meta tag database.
Can anyone give me an idea of a good way to accomplish this.
Right now you have to edit the template and it be the same meta tags for every page, which really is not a good way to get good results in the search engines. If I have the meta tags in a database and it was based on the category, then they would change based on the search and be more accurate. So when the search bots ran thru the links of my site they would index meta tags that were accurate and help with better placement. I hope this makes sense? Note these pages are guest pages and there is no login required.
Kim <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=10973&image=1&table=forumtopics' class='bbc_emoticon' alt=':)' />

H
horsey_kim author 3/3/2009

Does anyone have an idea of how to accomplish this?
Kim

Sergey Kornilov admin 3/3/2009

Kim,
you can use "Insert PHP code snippet" function to run some PHP code that retrieves data from the database and displays it in a form of META tags.

H
horsey_kim author 3/6/2009

SWEET - here is what I did if anyone is interested:

  1. created a metatag database where I defined keywords, description, title and category.
  2. In my main database where the listing items are I included a category field also.
  3. I created a list page for the main database fields.
  4. I then added this snippet. I made code for each meta tag I wanted. (I am not smart enough to figure out how to keep the $name for the search for stick for each echo, if I lumped them together)

global $conn, $strTableName;

if ($_SESSION[$strTableName."_searchfor"])

{$metakeyword = $_SESSION[$strTableName."_searchfor"];

$strSQL = "SELECT keywords, category FROM metatag WHERE category = '$metakeyword'";

$rs = db_query($strSQL,$conn);

while ($data = db_fetch_array($rs))

echo"<meta name='keywords' content='".$data["keywords"]."'>";

}
if ($_SESSION[$strTableName."_searchfor"])

{$metadescr = $_SESSION[$strTableName."_searchfor"];

$strSQL = "SELECT description, category FROM metatag WHERE category = '$metadescr'";

$rs = db_query($strSQL,$conn);

while ($data = db_fetch_array($rs))

echo"<meta name='description' content='".$data["description"]."'>";

}
if ($_SESSION[$strTableName."_searchfor"])

{$metatitle = $_SESSION[$strTableName."_searchfor"];

$strSQL = "SELECT title, category FROM metatag WHERE category = '$metatitle'";

$rs = db_query($strSQL,$conn);

while ($data = db_fetch_array($rs))

echo"<TITLE>".$data["title"]."</TITLE>";

}


5. I then switched from visual mode to code mode and deleted out the default <title> tag. The snippet needs to be placed above the </head> tag, and when you do that the visual editor in visual modes put in additional pre </body> tags such as <body> <head>. So make all your visual changes first and save the snippet last. Click to code mode and edit, DO NOT CLICK back to visual or you get all these extra tags put back in.
6. Then built and uploaded and it worked great.
Jane or Sergey, is there a way to not have the extra <body><head><title> tags show up when you click back to visual?

H
horsey_kim author 3/7/2009

Just tried it on another website and if I go back to visual mode on that one, it adds an extra <META content="MSHTML 6.00.6000.16809" name=GENERATOR>, moves my snippet to under the <body> tag and moves the style.css link to after the </head><body> tags.

Sergey Kornilov admin 3/7/2009

Kim,
IE-based HTML editing engine adds those tags automatically and there is not easy way to prevent this from happening.

500452 3/9/2009

How can i use the title and description that I want to use? I don't care if they are all the same.
I'm sorry I don't understand after reading the manual!

J
Jane 3/11/2009

Hi,
what title and description do you mean?

Please clarify.

500453 3/12/2009

Hi,

what title and description do you mean?

Please clarify.


I note that there are many variables such as this one for the list page. Is there a way for me to change this to the title I want?
$caption pedigrees =
<TITLE>{$caption pedigrees}</TITLE>
Also, I want to add <META> tags for the website description and key words and put something in $header.
<META content="MSHTML 6.00.6001.18203" name=GENERATOR></HEAD>

<BODY topMargin=5 {$bodyattrs}>{BEGIN body}{$header}
tks

J
Jane 3/13/2009

Mary,
you can edit caption manually and add your custom code on the Visual Editor tab in HTML mode.

500454 3/13/2009

Mary,

you can edit caption manually and add your custom code on the Visual Editor tab in HTML mode.


So, there is NOT a page of variables somewhere that can be edited? I don't like the manual changes because, if I have to reset the page, I lose those changes. Also I tend to make errors that prevent the pages from working properly . . .
I sure like the changes made to 5.0 that do away with the "Smarty" code. It is much easier to understand.
Thanks!