Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic Meta Tags

Status
Not open for further replies.

liliafan

Programmer
Jun 18, 2000
2
GB
Hi I am fairly new to coldfusion programming (3-4months) and now I am working on an entirely datadriven site the structure of the site remains the same throughout, and as such I am using templates and just altering the contents of the page.<br><br>The problem I have is the the client wants to have meta tags included on every page, this is proving to be a problem for me I have spent a couple of hours trying to come up with a way of doing it. <br><br>First I tried doing a &lt;cfquery&gt; using the pagename as the primary key and calling entries in the database and inserting them as variables in the template.&nbsp;&nbsp;Now I am trying using &lt;cfset&gt; then performing a call to the template and using the set variables and entries into the meta tags:<br><br>&lt;cfset keyword1='something'&gt;<br>&lt;cfset keyword2='something'&gt;<br>&lt;cfset keyword3='something'&gt;<br>&lt;cfset keyword4='something'&gt;<br>&lt;cfset keyword5='something'&gt;<br>&lt;cfset keyword6='something'&gt;<br>&lt;cfset author='something'&gt;<br><br>&lt;CFINCLUDE TEMPLATE=&quot;temp-top.cfm&quot;&gt;<br><br>the template has the following:<br><br>&lt;script language=&quot;JavaScript&quot; src=&quot;js/arrays.js&quot;&gt;&lt;/script&gt;<br>&lt;cfoutput&gt;<br>&lt;meta name=&quot;keywords&quot; content=&quot;#keyword1#, #keyword2#, #keyword3#, #keyword4#, #keyword5#, #keyword6#&quot;&gt;<br>&lt;meta name=&quot;author&quot; content=&quot;#author#&quot;&gt;<br>&lt;/cfoutput&gt;<br>&lt;/head&gt;<br><br>But for some reason this is refusing to work for me, does anyone have any ideas or suggestions as to how I may fix this problem?<br><br>Thanks for any help you may have.<br><br>Ben
 
Well usually META tags are the same on every page, so why don't you just do a CFINCLUDE and include a file that contains the meta tags.<br><br>If you want different meta tags on each page then simple use CFSWITCH and CFCASE to setup a selection of different meta tags in your INCLUDE file and test for example for the existance of a URL variable.<br><br>If you have a dynamic template that includes the different pages of your site then obviously you must already be sending a URL variable to tell the template which file to include, so also use this to decide which meta tag to use.<br><br>SIMPLE.<br><br> <p>Russ Michaels<br><a href=mailto:russ@satachi.com>russ@satachi.com</a><br><a href= Internet Development</a><br>Rapid Web application development, specialising in Coldfusion, database integration and e-commerce solutions.
 
The problem being that the client has requested I use a Perl search engine :eek:p although it is against my better judgement they are a big contract and sometimes it is easier not to argue than lose the contract, the perl engine they want me to use, searches through the meta tags, to find pages and display results, which brings me back to needing to dynamically alter the contents of the head.<br><br>This site is in excess of about 700 pages so using plain html really isn't an option, which is why I choose to use coldfusion instead as it makes things a lot easier on me.&nbsp;&nbsp;<br><br>So is there actually anyway to alter the meta tags from a header document?<br><br>Ben
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top