booklive Posted July 20, 2012 Share Posted July 20, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/265993-dynamically-creating-meta-tags-from-separate-tables/ Share on other sites More sharing options...
xyph Posted July 20, 2012 Share Posted July 20, 2012 echo stripslashes($rowcategory->metadesc) .', '. $cityname; I'm not exactly sure what your current output, and your expected output is so I can only guess. Quote Link to comment https://forums.phpfreaks.com/topic/265993-dynamically-creating-meta-tags-from-separate-tables/#findComment-1363060 Share on other sites More sharing options...
booklive Posted July 20, 2012 Author Share Posted July 20, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/265993-dynamically-creating-meta-tags-from-separate-tables/#findComment-1363072 Share on other sites More sharing options...
xyph Posted July 20, 2012 Share Posted July 20, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/265993-dynamically-creating-meta-tags-from-separate-tables/#findComment-1363077 Share on other sites More sharing options...
booklive Posted July 20, 2012 Author Share Posted July 20, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/265993-dynamically-creating-meta-tags-from-separate-tables/#findComment-1363079 Share on other sites More sharing options...
xyph Posted July 20, 2012 Share Posted July 20, 2012 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? Quote Link to comment https://forums.phpfreaks.com/topic/265993-dynamically-creating-meta-tags-from-separate-tables/#findComment-1363082 Share on other sites More sharing options...
booklive Posted July 20, 2012 Author Share Posted July 20, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/265993-dynamically-creating-meta-tags-from-separate-tables/#findComment-1363107 Share on other sites More sharing options...
xyph Posted July 20, 2012 Share Posted July 20, 2012 Do the exact same thing for your description. Append . $city_page_title to the echo. That should work. Quote Link to comment https://forums.phpfreaks.com/topic/265993-dynamically-creating-meta-tags-from-separate-tables/#findComment-1363109 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.