Jump to content

Dynamically creating meta tags from separate tables


booklive

Recommended Posts

I need to be able to add a location to the category page meta-descriptions so they differ from the current dynamically generated pages. Each category has a generic page ie 'Great things to hire' and 36 demographic pages for each category ie 'Great things to hire London'

 

I currently have this:

 

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9, IE=EmulateIE8, IE=EmulateIE7" />

<title><?php echo stripslashes($rowcategory->titlebar) . $city_page_title;?></title>

<meta name="description" content="<?php echo stripslashes($rowcategory->metadesc);?>">

<meta name="keywords" content="<?php echo stripslashes($rowcategory->metakey);?>">

 

How do I also include the relevant $cityname into the meta description so it differs from the generic page in that category and will stop search engines finding duplicate metatags?

 

Thanks very much in advance

Link to comment
Share on other sites

Thanks for looking.

 

The current output for the meta description for an example category e.g wedding music is:

 

Hire wedding music, bands, singers for weddings and corporate entertainment

This is taken from the cms <meta name="description" content="<?php echo stripslashes($rowcategory->metadesc);?>">

 

The phpmyadmin includes a table where the 'category' is defined and the meta description and metakeywords are also defined.

 

Within the wedding music category there are 36 regions in the UK - each of which have their own page e.g weddding music London, wedding music Birmingham etc. Currently these all inherit the same meta description with no location defined.

 

I am wanting to include the relevant location in each of the 36 category region pages' meta descriptions. Within phpmyadmin there is a table containing the 36 location names $cityname

 

Can I echo the $cityname even though it is in a different cms table - like so?:

<meta name="description" content="<?php echo stripslashes($rowcategory->metadesc);? . $cityname;?>">

 

How can I generate the meta description to include the same location as the one included in the title?

 

Thank you so much in advance

Link to comment
Share on other sites

It's hard to say, you're the one defining the variables here, I'm trying to help with a very limited scope on your application.

 

Is $cityname defined in your application? If so, yes, you can use it.

Link to comment
Share on other sites

Thank you. I started looking into php mysql 2 days ago. Rather than start afresh I thought I would try and understand what my previous developer did for me. I saw this isssue and thought I would try and solve it - I appreciate that it is not a simple task but thought I'd see if I was on the right track.

 

I'm still not sure it will work as it needs to generate the same $cityname as the one being generated in the title

 

Thank you for your input

Link to comment
Share on other sites

Yeah, it's hard to help without a decent understanding of the application on either end.

 

If the value you want is generated elsewhere on the page, there's no reason you can't use it in the description.

 

Could you post an example output of the entire section of code in your original post?

Link to comment
Share on other sites

Cheers xyph

 

I asked my previous web guy to add fields within the cms so I could micromanage the meta data. He coded the Page titles so I could input the text into fields for the title, description and keywords. He then generated the title location by including the $city_page_title;?>:

<title><?php echo stripslashes($rowcategory->titlebar) . $city_page_title;?></title>

 

I forgot to ask him to include the location in the meta description code though. Is this helpful?

 

Hindsight ftw!

 

Thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.