By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,130 Members | 2,141 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,130 IT Pros & Developers. It's quick & easy.

How do i add dynamic meta tags to a database driven asp page

100+
P: 114
I have a news website, with asp pages. It has publishing software which allows you to add articles in a database, and then calls them up from links etc. I have added dynamic meta tags in 2 parts. The first part is in the inc.header.asp file which is called up on every page. The page itself has the meta tag variable, ie. title, description. They work fine on all pages, except the one below i'm having problems with. Ironically it's the most important page, because it's the page that shows the full page article. (view.asp) The reader reaches view.asp by clicking on the article headline in the page before for example here it is called "articlelist.asp". I have included relevant code from the 2 pages here,


Here is a bit of relevant code from the page where the news links are listed (lets call it "articlelist.asp") is this one, and here is one such link, which is a headline, summary and possible image, and other info.

Expand|Select|Wrap|Line Numbers
  1.                     <div align="justify"><a class="aTITLE_BLUE" href="view.asp?ID=<%=NID%>"><%=TITLE%></a><br />                    
  2.                                                 <%IF NOT (IMAGE = "" OR IsNull(IMAGE)) THEN%>
  3.                       <img src="<%=IMAGE%>" width="50" height="50" align="left" />
  4.                       <%END IF%>                    
  5.       <span class="style2"><%= FormatDateTime(POSTED,DATE_F) %></span> <span class="tdSUMMARY"><%= SUMMARY %> </span>
  6.       <%IF NOT I_SIDE = SHOW_HL THEN%>
  7.     </div>
  8.                     <hr align="JUSTIFY">
  9.                     <div align="justify">
  10.                       <%End If%>
When a reader clicks on the link above, it takes them to the complete article which is view.asp page with the added NID article number showing in the url.

What happens at present , is that the meta tags on all the view.asp pages are the same, as i've put them at the top of the view.asp page. Obviously i need to add them to the article when i do it at the admin side of the software. These articles are not as include files Bill, the include files are soemthing else. The articles are pulled up as you will see below.



Below are the relevant parts of the view.asp page, where the article is actually shown. The page is split in 3 columns. The first column is called "left column" there is some code here, which i didn't bother showing you as the article is in the middle column, ie. "main article" column which is where the news article is pulled from the database, and the third column is pulled from "inc.footer.asp", again irrelevant. Thus the "left column" and "inc.footer" column are no problem, its the "main article" that needs attention and as you will see the title of the article is called from the database. It is included in the page content, but i want to make sure that each view.asp page shows the title and other meta detail . From the code that shows now, the meta tags are always the same no matter what the article as they are added at the top of the view.asp. I need to add them to the database i think. Am i correct? I hope not, i hope i can add them to the article when i am adding it from the admin software.....i tried this, ie. adding it as code, but the problem then was it didn't show in the header of the view.asp page, it showed only in the content of the article when i viewed "view source" from the web.


Expand|Select|Wrap|Line Numbers
  1. <% 
  2. title = "article title" 
  3. meta_description = "the description goes here" 
  4. meta_keywords = "this, is, the, keyword, section," 
  5. %> 
  6. <!--#include file="inc_header.asp"--> 
  7.  
  8.  
  9.  <% Dim SQL, RS, ID, TITLE, CONTENT, SUMMARY, POSTED, ALLOW_C, ALLOW_V, UPDATED, MESSAGE, VOTED, ALLOW_V_MAIN, _
  10.            ALLOW_C_MAIN, NID, AUTHOR, CATEGORIES, AID, USE_VIEW, NIMAGE
  11.           Dim CCOUNT, C_ID, C_NAME, C_EMAIL, C_COMMENT, C_DATE, C_SUBJECT, C_M_ID, C_ALLOW_E, C_CITY, C_COUNTRY, _
  12.               RCOUNT, RID, RTITLE, ACOUNT
  13.  
  14.  
  15.     NID   = Trim(Request.QueryString("ID"))
  16.     VOTED = Trim(Request.Cookies("NEWS_ARTICLE_" & NID))    
  17.     MEMBER_ID = Trim(Session("PMMS_ID"))    
  18.     IF Trim(Session("PMMS_IN")) = "True" THEN blLOGGED_IN = True    
  19.  
  20.     IF IS_VALID_ID(NID) THEN
  21.  
  22.         Call OPEN_DB() 
  23.  
  24.         SQL = "SELECT fldA_V, fldA_C FROM nm_tbl_settings WHERE ID = 1"
  25.         Set RS = Server.CreateObject("ADODB.Recordset")
  26.         RS.LockType   = 1
  27.         RS.CursorType = 0
  28.         RS.Open SQL, MyConn    
  29.              IF NOT RS.EOF THEN
  30.                  ALLOW_V_MAIN = trim(RS("fldA_V"))
  31.                 ALLOW_C_MAIN = trim(RS("fldA_C"))
  32.              END IF
  33.         RS.Close        
  34.  
  35.         SQL = "UPDATE nm_tbl_news SET fldVIEWS = fldVIEWS + 1 WHERE ID = " & NID
  36.         MyConn.Execute(SQL)
  37.  
  38.         SQL = "SELECT fldTITLE, fldCONTENT, fldSUMMARY, nm_tbl_news.fldACTIVE AS ACTIVE, fldAID, fldPOSTED, fldEXPIRES, nm_tbl_news.fldIMAGE AS NIMAGE, fldALLOW_COMMENTS, fldALLOW_VOTING, fldCREATED, fldUPDATE, nm_tbl_agent.fldNAME AS ANAME, nm_tbl_news.fldAID AS AID, fldUSE_VIEW FROM nm_tbl_news, nm_tbl_agent WHERE (nm_tbl_agent.ID = nm_tbl_news.fldAID) AND (nm_tbl_news.fldACTIVE = 1) AND nm_tbl_news.ID = " & NID ' { AND (Now() - {GetDate()} BETWEEN fldPOSTED AND fldEXPIRES)) }
  39.         response.write vbNewLine & "<!-- SQL: " & SQL & " -->" & vbNewLine
  40.         Set RS = Server.CreateObject("ADODB.Recordset")
  41.         RS.LockType   = 1
  42.         RS.CursorType = 0
  43.         RS.Open SQL, MyConn    
  44.              IF NOT RS.EOF THEN
  45.                  TITLE   = trim(RS("fldTITLE"))
  46.                 CONTENT = trim(RS("fldCONTENT"))
  47.                 SUMMARY = trim(RS("fldSUMMARY"))
  48.                 POSTED  = trim(RS("fldPOSTED"))
  49.                 ALLOW_C = trim(RS("fldALLOW_COMMENTS"))
  50.                 ALLOW_V = trim(RS("fldALLOW_VOTING"))
  51.                 UPDATED = trim(RS("fldUPDATE"))
  52.                 AUTHOR  = trim(RS("ANAME"))
  53.                 AID     = trim(RS("AID"))
  54.                 USE_VIEW= trim(RS("fldUSE_VIEW"))
  55.                 NIMAGE  = trim(RS("NIMAGE"))                
  56.              ELSE   
  57.                 MESSAGE = MESSAGE & "<li />This article is currently not available."
  58.              END IF
  59.              response.write vbNewLine & "<!-- SQL: " & SQL & " -->" & vbNewLine
  60.         RS.Close 
  61.  
  62.         CONTENT = ReplaceAuthorTokens(AID, CONTENT)        
  63.         CATEGORIES = GET_CATES(NID)
  64.  
  65.         ' Get settings
  66.         Dim DATE_F
  67.         DATE_F = GET_SETTINGS(False, "fldDATE_F")        
  68.  
  69.         TITLE = PROCESS_SHORTCUTS(False, TITLE)
  70.         CONTENT = PROCESS_SHORTCUTS(False, CONTENT)
  71.         SUMMARY = PROCESS_SHORTCUTS(False, SUMMARY)
  72.  
  73.     ELSE
  74.  
  75.       MESSAGE = MESSAGE & "<li />No article has been found."
  76.  
  77.     END IF
  78.     %>
  79.  
  80.     <% IF NOT MESSAGE = "" THEN %>
  81.         <!--#include file="inc_error.asp"-->
  82.  
  83.         <% Response.End %>
  84.     <% END IF %>            
  85.  
  86.  
  87.     <%IF USE_VIEW = "1" THEN ' News Agency Template %>        
  88.  
  89.  
  90.             <table width="658" align="center" cellpadding="2" cellspacing="0" border="0">
  91.               <tr>
  92.                 <td width="150" valign="top">
  93.                     <!-- Left Column -->
  94.  
  95.  
  96.  
  97.                     <!-- [ Left Column ] -->                </td>
  98.                 <td width="460" valign="top">
  99.                     <!-- Main Article -->
  100.  
  101.  
  102.                         <table width="100%" border="0" align="center" cellpadding="2" cellspacing="0">
  103.  <tr>
  104.    <td colspan="6" align="left" class="ArticleTitle"><%= TITLE %></td>
  105.    <tr>
  106.     <td align="left" valign="bottom">Filed under  <em><%=CATEGORIES%></em> - on <%= FormatDateTime(POSTED,DATE_F) %>
  107.         <%IF SHOW_AUTHOR = True THEN%> - By: <%=AUTHOR%> <%END IF%> </td>      
  108.  
  109.  
  110.                         <hr size="1" style="color: grey;height: 3px;width: 100%;"/>
  111.    <div class="tdSUMMARY"><%=CONTENT%></div> <br />
  112.  
  113.      <br />
  114.      <br />
  115.  
  116.      <a href="#talkback1" class="CateLink" >Comment on this article! Talkback</a><br />
  117.  
  118.  
  119.  
  120.                         <% END IF ' { IF USE_VIEW = "1" THEN ' News Agency Template  } %>
  121.  
  122.  
  123.   <p>&nbsp;        </p>
  124.                             <p>
  125.  
  126.  
  127.     <%
  128.     MyConn.close     
  129.     Set MyConn = Nothing    
  130.     %>  
  131. <!--#include file="inc_footer.asp"-->    
Aug 30 '07 #1
Share this Question
Share on Google+
21 Replies


jhardman
Expert 2.5K+
P: 3,405
From your post, it appears you know how to get the data from the database, but don't know how to put it in your web page. If that is the case, this is the solution:
Expand|Select|Wrap|Line Numbers
  1. <% 
  2. title = "article title" %>
  3. <title><%=title%></title>
  4. <%
  5. meta_description = "the description goes here" %>
  6. <meta name="description" content="<%=meta_description%>">
  7. <%
  8. meta_keywords = "this, is, the, keyword, section," %> 
  9. <meta name="keywords" content="<%=meta_keywords%>">
  10. <!--#include file="inc_header.asp"-->
Although it sure would be useful if this was in the inc_header.asp file. Are you sure it's not there?

Jared
Aug 31 '07 #2

markrawlingson
Expert 100+
P: 346
Or is it that you want the meta tags to be different depending on which article they user is looking at? Like if they're looking at "How to build a dog house" then the meta tag would be

Keywords="dog house, dog, house, building, do it yourself, DYI"

or if they're looking at "Home remedies to get rid of a rash"

Keywords="rash, itchy, home remedies, remedies"

??
Aug 31 '07 #3

100+
P: 114
Or is it that you want the meta tags to be different depending on which article they user is looking at? Like if they're looking at "How to build a dog house" then the meta tag would be

Keywords="dog house, dog, house, building, do it yourself, DYI"

or if they're looking at "Home remedies to get rid of a rash"

Keywords="rash, itchy, home remedies, remedies"

??
yes MarkRawlingson, that is what i want. Otherwise at the moment, the tags work perfectly onall the pages. They even work on the view.asp page but this is the page that needs to pull up the article from the database. As you can see, the way they are now, they pull up all the same on every page. They work, but i need to draw the variable from the middle of the page from the article in the database. its a stupid complicated problem to me but maybe there is a simple solution?

im not html literate, and i hope i don't have to fiddle with the database, as it was done for me. Im hoping there is a simple solution to this.


The main problem seems to be that the templates for the articles are in the software, which means when i add them to the content of the article they show (only in "view source" though) in the content, not in the header, like i want them to.

Thanks for any tips, bear in mind, im not html literate.
Aug 31 '07 #4

100+
P: 114
From your post, it appears you know how to get the data from the database, but don't know how to put it in your web page. If that is the case, this is the solution:
Expand|Select|Wrap|Line Numbers
  1. <% 
  2. title = "article title" %>
  3. <title><%=title%></title>
  4. <%
  5. meta_description = "the description goes here" %>
  6. <meta name="description" content="<%=meta_description%>">
  7. <%
  8. meta_keywords = "this, is, the, keyword, section," %> 
  9. <meta name="keywords" content="<%=meta_keywords%>">
  10. <!--#include file="inc_header.asp"-->
Although it sure would be useful if this was in the inc_header.asp file. Are you sure it's not there?

Jared
Jared, i already have the inc.header file set up, and the meta tags work on all pages dynamically. They even work on the view.asp page.

MarkRawlingson above understood what i meant i think.

Thank you both for replying. Much appreciated:)
Aug 31 '07 #5

markrawlingson
Expert 100+
P: 346
It is a simple solution and there are numerous ways you could go about doing this - you COULD include the keywords in the database. It would be the easiest and most direct way of doing things. The only problem is you would have to manually define the keywords yourself before placing them into the database.

Expand|Select|Wrap|Line Numbers
  1. <meta keywords="<%=rs("mykeywords")%>">
  2.  
which would pull your keywords from the database and apply them to the meta tag depending on which article the individual is looking at. Similarly with the other meta.

That would be the simplest and easiest solution, however if you really don't want to touch the database then I would suggest using a SELECT CASE statement or a series of If.. Elseif.. Else.. statements

Expand|Select|Wrap|Line Numbers
  1. <%
  2. SELECT CASE Request.Querystring("id")
  3.      CASE "1"
  4.           sKeywords = "Dog, Dog House, House, DYI, Do It Yourself"
  5.      Case "2"
  6.           sKeywords = "keyword1, keyword2, keyword3"
  7. %>
  8. <meta keywords="<%=sKeywords%>">
  9.  
This could get complicated VERY quickly because you would have to manually input each list of keywords into your script for each individual article.

You could write a very complicated function to scrape the article itself for predefined keywords, based off of the article's title i guess (?), place them into a string, and then put that into the meta tag - that would be a really large pain in the butt.. but the end result would be pretty neat if you could pull it off.
Aug 31 '07 #6

100+
P: 114
It is a simple solution and there are numerous ways you could go about doing this - you COULD include the keywords in the database. It would be the easiest and most direct way of doing things. The only problem is you would have to manually define the keywords yourself before placing them into the database.

Expand|Select|Wrap|Line Numbers
  1. <meta keywords="<%=rs("mykeywords")%>">
  2.  
which would pull your keywords from the database and apply them to the meta tag depending on which article the individual is looking at. Similarly with the other meta.

That would be the simplest and easiest solution, however if you really don't want to touch the database then I would suggest using a SELECT CASE statement or a series of If.. Elseif.. Else.. statements

Expand|Select|Wrap|Line Numbers
  1. <%
  2. SELECT CASE Request.Querystring("id")
  3.      CASE "1"
  4.           sKeywords = "Dog, Dog House, House, DYI, Do It Yourself"
  5.      Case "2"
  6.           sKeywords = "keyword1, keyword2, keyword3"
  7. %>
  8. <meta keywords="<%=sKeywords%>">
  9.  
This could get complicated VERY quickly because you would have to manually input each list of keywords into your script for each individual article.

You could write a very complicated function to scrape the article itself for predefined keywords, based off of the article's title i guess (?), place them into a string, and then put that into the meta tag - that would be a really large pain in the butt.. but the end result would be pretty neat if you could pull it off.
thnak you MarkRawling

well i have to add each article manually into the database throught the admin. USing a template. I prefer the 2nd method, if there isn't anything better, Where does the code actually go on the page? ie. where do i put it?

I think the last solution would be the best, if i could pull up the title from the title string that would be great. and Description could be the first 10 words of the summary, or something
Aug 31 '07 #7

markrawlingson
Expert 100+
P: 346
It will go somewhere at the top of your page, so that you can define the keywords - and then set them into the meta tags.

so...

Expand|Select|Wrap|Line Numbers
  1. <%
  2. 'pull down the ID from the querystring that pertains to the record that you want to set keywords for
  3. select case Request.QueryString("id")
  4.      Case "1" 'If the ID from the qstring = 1 Then the keywords will be as follows
  5.           sKeywords = "some, keywords, associated, with, the, article"
  6.      Case "2" 'if the id from the qstring = 2 then the keywords will be different
  7.           sKeywords = "some, keywords, which, are, different"
  8. End Select
  9. 'You're setting the keywords into a variable, and then spitting that variable out into the meta tag. Whatever 'sKeywords' holds, the meta tag will hold. You could set your description and other meta tags similarly.
  10. %>
  11. <html>
  12. <head>
  13. <title><%=articletitle%></title>
  14. <!--Set the keywords into the meta tag itself. -->
  15. <meta keywords="<%=sKeywords%>">
  16. </head>
  17. <body>
  18. </body>
  19. </html>
  20.  
I do warn you though, If you do it this way you will have to manually define different keywords for each article.. if you don't they won't show up. So say you have 1000 articles... Well, you get the picture!

The last solution would be very difficult to accomplish.. You would have to basically have an asp function written that would grab the title of the article, and cross reference the content of the article, scraping out keywords from it that pertain to the title - and then set the keywords into the meta tag. It depends on your level of expertise.

Sincerely,
Mark
Aug 31 '07 #8

100+
P: 114
It will go somewhere at the top of your page, so that you can define the keywords - and then set them into the meta tags.

so...

Expand|Select|Wrap|Line Numbers
  1. <%
  2. 'pull down the ID from the querystring that pertains to the record that you want to set keywords for
  3. select case Request.QueryString("id")
  4.      Case "1" 'If the ID from the qstring = 1 Then the keywords will be as follows
  5.           sKeywords = "some, keywords, associated, with, the, article"
  6.      Case "2" 'if the id from the qstring = 2 then the keywords will be different
  7.           sKeywords = "some, keywords, which, are, different"
  8. End Select
  9. 'You're setting the keywords into a variable, and then spitting that variable out into the meta tag. Whatever 'sKeywords' holds, the meta tag will hold. You could set your description and other meta tags similarly.
  10. %>
  11. <html>
  12. <head>
  13. <title><%=articletitle%></title>
  14. <!--Set the keywords into the meta tag itself. -->
  15. <meta keywords="<%=sKeywords%>">
  16. </head>
  17. <body>
  18. </body>
  19. </html>
  20.  
I do warn you though, If you do it this way you will have to manually define different keywords for each article.. if you don't they won't show up. So say you have 1000 articles... Well, you get the picture!

The last solution would be very difficult to accomplish.. You would have to basically have an asp function written that would grab the title of the article, and cross reference the content of the article, scraping out keywords from it that pertain to the title - and then set the keywords into the meta tag. It depends on your level of expertise.

Sincerely,
Mark
OK, so i put this at the top of the view.asp page you mean?

i understand that,

but are 2 querystrings necessary, ie. "if"?
if querystring is 1,
if querysting is 2

or does it mean that for each article it continues, ie. 1, then 2 then 3, so if i had 1000 articles i would need to add 1000 times? this would mean i'd have a very long view.asp page?
Aug 31 '07 #9

markrawlingson
Expert 100+
P: 346
but are 2 querystrings necessary, ie. "if"?
if querystring is 1,
if querysting is 2
They wouldn't be necessary if you had a field in your database that held the keywords. Because then you could just "SELECT * FROM [tblArticles] WHERE iIDColumn = " & Request.Querystring("id")

Which would pull on only one specific record, pertinent to the one that the user is looking at. Then you could just pull the keywords out of a column in your table, and pop them into the meta tag - clean and easy.

However, if you don't want to / can't mess around with the database then you have to improvise.

So the suggestion is an improvisation - You are 100% correct that you will need to write out

Case #
sKeywords = "the keywords"

For each and every single article. A tedious process, and yes the view.asp page will be longer than 10 arm lengths... that you will have to keep adding to.

There's no two ways about it - You need to know two things : What article the viewer is looking at, and what keywords/meta information is relative to that specific article.
Sep 1 '07 #10

100+
P: 114
They wouldn't be necessary if you had a field in your database that held the keywords. Because then you could just "SELECT * FROM [tblArticles] WHERE iIDColumn = " & Request.Querystring("id")

Which would pull on only one specific record, pertinent to the one that the user is looking at. Then you could just pull the keywords out of a column in your table, and pop them into the meta tag - clean and easy.

However, if you don't want to / can't mess around with the database then you have to improvise.

So the suggestion is an improvisation - You are 100% correct that you will need to write out

Case #
sKeywords = "the keywords"

For each and every single article. A tedious process, and yes the view.asp page will be longer than 10 arm lengths... that you will have to keep adding to.

There's no two ways about it - You need to know two things : What article the viewer is looking at, and what keywords/meta information is relative to that specific article.
OK thanks for the tip Mark, i will now try it out,

I just had an idea, that may make the view.asp


couldn't i add the variables to another separate page that i create? ie. let's call it variables.htm
Would it work then? I dont want an uneccesarily long view.asp page in case anyone looks at the source code, in that case, they'll see a long list of keywords, as i plan to add at least 6 articles daily.

Thanks, so much
Sep 1 '07 #11

markrawlingson
Expert 100+
P: 346
You could, it wouldn't make it any easier to do but it would at least keep the superflous code in a separate file. If you do that i'd suggest just having a separate .asp file as an include with the select case stuff in there.
Sep 1 '07 #12

100+
P: 114
You could, it wouldn't make it any easier to do but it would at least keep the superflous code in a separate file. If you do that i'd suggest just having a separate .asp file as an include with the select case stuff in there.
yes i realise the work wouldn't be any the less, but it would make the view.asp page neater should anyone view the code.

So assuming the separate file is called "meta.asp" , the code at the top of the view.asp page should start
Expand|Select|Wrap|Line Numbers
  1.  <!--#include file="meta.asp"-->
and in the meta.asp file i should do this,


Expand|Select|Wrap|Line Numbers
  1. <%
  2. 'pull down the ID from the querystring that pertains to the record that you want to set keywords for
  3. select case Request.QueryString("id")
  4.      Case "1" 'If the ID from the qstring = 1 Then the keywords will be as follows
  5.           sKeywords = "some, keywords, associated, with, the, article"
  6.      Case "2" 'if the id from the qstring = 2 then the keywords will be different
  7.           sKeywords = "some, keywords, which, are, different"
  8. End Select
  9. 'You're setting the keywords into a variable, and then spitting that variable out into the meta tag. Whatever 'sKeywords' holds, the meta tag will hold. You could set your description and other meta tags similarly.
  10. %>
  11. <html>
  12. <head>
  13. <title><%=articletitle%></title>
  14. <!--Set the keywords into the meta tag itself. -->
  15. <meta keywords="<%=sKeywords%>">
  16. </head>
  17. <body>
  18. </body>
  19. </html>
Just to clarify, does the above code show the title, and keywords?

thanks , so much Mark
Sep 1 '07 #13

markrawlingson
Expert 100+
P: 346
I would set meta.asp to hold JUST the dynamic creation of the meta information.
If you want to set the title, i would just grab that from the database - I'm assuming you at least have a column in the database that holds the title of the article?

META.ASP
Expand|Select|Wrap|Line Numbers
  1. <%
  2. SELECT CASE Request.QueryString("ArticleID")
  3.      CASE 1
  4.          sKeywords = "whatever"
  5.      Case 2
  6.          etc
  7.  
Then include it into view.asp

Expand|Select|Wrap|Line Numbers
  1. <!--#include File="meta.asp"-->
  2. <html>
  3. <head>
  4. <title><%=rs("sTItle")%></title>
  5. <meta keywords="<%=sKeywords%>">
  6. </head>
  7. <!--rest of your page-->
  8.  
Sep 1 '07 #14

100+
P: 114
From your post, it appears you know how to get the data from the database, but don't know how to put it in your web page. If that is the case, this is the solution:
Expand|Select|Wrap|Line Numbers
  1. <% 
  2. title = "article title" %>
  3. <title><%=title%></title>
  4. <%
  5. meta_description = "the description goes here" %>
  6. <meta name="description" content="<%=meta_description%>">
  7. <%
  8. meta_keywords = "this, is, the, keyword, section," %> 
  9. <meta name="keywords" content="<%=meta_keywords%>">
  10. <!--#include file="inc_header.asp"-->
Although it sure would be useful if this was in the inc_header.asp file. Are you sure it's not there?

Jared
Mark, thank you i will try to work out and fix using your style. But after reviewing the thread, i just realised something else after re-reading what Jared said,


Since i already have the title column in the database, how about i use the title for the meta tags ie. all of them? is that OK?

for example
title could be Title
description could be Title
and keywords could be Title

all the above would be ok i think, and so much more simpler.

What do you both think? sorry about this Mark, after making you write all that, i realised this afterwards, so sorry.

The title of the article is drawn up as <%= TITLE %>
Let me show code which i have at present,

in the view.asp page at the top it says:
Expand|Select|Wrap|Line Numbers
  1. <% 
  2. title = "title"
  3. meta_description = "description here" 
  4. meta_keywords = "keywords here" 
  5. %> 
  6. <!--#include file="inc_header.asp"--> 
and in the inc.header.asp it says:

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head> 
  3. <title><%=title%></title> 
  4. <meta name="Description" content="<%=meta_description%>"<meta> 
  5. <meta name="Keywords" content="<%=meta_keywords%>"<meta> 
I'd like the title to work in title, description and keywords meta tags, ie. if i put
<%= TITLE %> in the tags instead of meta descriptin and meta keywords would it work?
Im thinking it will in description, but in keywords you need comma,s in don't you?

Bear in mind that the code above works on all pages, but i put it there manually. On the view.asp page the pages will be drawn from the database, that's why im having to fiddle with it.

After all this i realised it may be much simpler to change the code to have all 3 meta tags show the title which is drawn out of the database.

What do you and Jared think? I think this was what Jared first recommended,
Sep 1 '07 #15

markrawlingson
Expert 100+
P: 346
Yeah you could do that - it will definately work! The only problem with that is that all your meta tags will hold all the same information, and the keywords won't be very useful - which is why i recommended actually setting up keywords specificly descriptive of the article.

However, if you're not really concerned with the actual information that's held within the meta tags - then definately that would be a MUCH easier way to go.

Sincerely,
Mark
Sep 1 '07 #16

100+
P: 114
Yeah you could do that - it will definately work! The only problem with that is that all your meta tags will hold all the same information, and the keywords won't be very useful - which is why i recommended actually setting up keywords specificly descriptive of the article.

However, if you're not really concerned with the actual information that's held within the meta tags - then definately that would be a MUCH easier way to go.

Sincerely,
Mark
OK Mark, bearing in mind that the title is drawn up by <%= TITLE %> , i presume i should use the code below, which means that i've only changed the view.asp page code , the inc.header.asp is the same. and yes, if iuse the keywords to be teh same as title thats ok. I was more worried about them not having commas. do they still come up even without comma's?

thanks so much.

anyway, in the view.asp page at the top it should say:


Expand|Select|Wrap|Line Numbers
  1. <% 
  2. title = "<%= TITLE %>"
  3. meta_description = "<%= TITLE %>" 
  4. meta_keywords = "<%= TITLE %>" 
  5. %> 
  6. <!--#include file="inc_header.asp"-->

and in the inc.header.asp it should say


<
Expand|Select|Wrap|Line Numbers
  1. html>
  2. <head> 
  3. <title><%=title%></title> 
  4. <meta name="Description" content="<%=meta_description%>"<meta> 
  5. <meta name="Keywords" content="<%=meta_keywords%>"<meta>
I hope the above is OK, what do you think?

Again many thanks.
Sep 1 '07 #17

markrawlingson
Expert 100+
P: 346
Keywords are separated with commas. So the whole title will show up as 1 single keyword.

"the title of the article" will be one keyword, rather than : "the, title, of, the, article" as 5 keywords.

It'll work though, and yeah the code you provided should work great for your purposes so long as <%= TITLE %> reprsents the title coming from the database of course!

Sincerely,
Mark
Sep 1 '07 #18

100+
P: 114
OK, i tried it and i received this error message when you check the page on the web

Expand|Select|Wrap|Line Numbers
  1. Microsoft VBScript compilation error '800a0409' 
  2.  
  3. Unterminated string constant 
  4.  
  5. /view.asp, line 2 
  6.  
  7. title = "<%= TITLE
  8. ------------------^
This is the relevant part of the code i used, in the inc.header.asp

Expand|Select|Wrap|Line Numbers
  1. <!--#include file="config.asp"-->
  2. <!--#include file="inc_api.asp"-->
  3. <% Response.Buffer = True %>
  4.  
  5. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  6. <html>
  7. <head> 
  8. <title><%=title%></title> 
  9. <meta name="Description" content="<%=meta_description%>"<meta> 
  10. <meta name="Keywords" content="<%=meta_keywords%>"<meta> 
and this is the code i used at the top of the view.asp page

Expand|Select|Wrap|Line Numbers
  1. <% 
  2. title = "<%= TITLE %>" 
  3. meta_description = "<%= TITLE %>" 
  4. meta_keywords = "<%= TITLE %>" 
  5. %> 
  6. <!--#include file="inc_header.asp"--> 
Sep 2 '07 #19

markrawlingson
Expert 100+
P: 346
Expand|Select|Wrap|Line Numbers
  1. <% 
  2. title = "<%= TITLE %>" 
  3. meta_description = "<%= TITLE %>" 
  4. meta_keywords = "<%= TITLE %>" 
  5. %> 
  6. <!--#include file="inc_header.asp"-->
  7.  
You're putting asp delimiters inside of an asp delimiter block. Remove the <%= %>

Either

title = "TITLE"

or

title = TITLE

Depending on whether or now it's a variable or string text you're trying to set.

Mark
Sep 2 '07 #20

100+
P: 114
Expand|Select|Wrap|Line Numbers
  1. <% 
  2. title = "<%= TITLE %>" 
  3. meta_description = "<%= TITLE %>" 
  4. meta_keywords = "<%= TITLE %>" 
  5. %> 
  6. <!--#include file="inc_header.asp"-->
  7.  
You're putting asp delimiters inside of an asp delimiter block. Remove the <%= %>

Either

title = "TITLE"

or

title = TITLE

Depending on whether or now it's a variable or string text you're trying to set.

Mark
"sigh"
OK now i tried this, and the error went.

Expand|Select|Wrap|Line Numbers
  1. <% 
  2. title = "TITLE"
  3.  
  4. meta_description = "TITLE"
  5.  
  6. meta_keywords = "TITLE"
  7.  
  8. %> 
  9. <!--#include file="inc_header.asp"--> 
however, when i went to check view.asp on the web under "view source"
this code was at the top of the page, with the title not drawn from the database


Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head> 
  4. <title>TITLE</title> 
  5. <meta name="Description" content="TITLE"<meta> 
  6. <meta name="Keywords" content="TITLE"<meta> 
  7. <link rel="STYLESHEET" type="text/css" href="styles.css"> 
Sep 2 '07 #21

markrawlingson
Expert 100+
P: 346
If you're setting

title = "TITLE"

Then you're setting a variable called title to hold a STRING value of TITLE and you're not pulling it from the database at all.

To do that you'll need to open a connection object to the database, create a recordset object, pass an SQL statement into the recordset object and open it.

Then you can pull out the information like so

title = rs("nameofthetitlecolumn")

where rs is equal to whatever you named your recordset object

Mark
Sep 2 '07 #22

Post your reply

Sign in to post your reply or Sign up for a free account.