Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

dataset

[Resolvido] Meta tags num Include File

Recommended Posts

Prezados, boa tarde;

 

Não sei bem como explicar, vou tentar ser breve.

 

Tenho varias páginas .asp, eu pretendo colocar as metas tags abaixo num arquivo, por exemplo: metatags.asp

 

    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
   <meta http-equiv="cache-control" content="no-cache" />
   <meta http-equiv="expires" content="3600" />
   <meta name="revisit-after" content="2 days" />
   <meta name="robots" content="index,follow" />
   <meta name="publisher" content="Your publisher infos here ..." />
   <meta name="copyright" content="Your copyright infos here ..." />
   <meta name="author" content="Design: Wolfgang (www.1-2-3-4.info) / Modified: Your Name" />
   <meta name="distribution" content="global" />
   <meta name="description" content="Your page description here ..." />
   <meta name="keywords" content="Your keywords, keywords, keywords, here ..." />

 

Então eu chamaria em cada pagina asp assim:

<!-- #Include Virtual = "/comum/includes/divs/metatags.asp" -->

 

Isso facilitaria a manutenção, pois nao preciso editar todas as paginas caso tenha alguma alteração. Eu mudaria em um arquivo e pronto.

 

Gostaria de saber se funciona. Ou seja, motores de busca e etc.

 

Grato.

Compartilhar este post


Link para o post
Compartilhar em outros sites

olha este exemplo:

 

<%

'Default Const
Const DefaultTitle = "aqui_seu_titulo"
Const DefaultKeywords = "aqui,sua,keyword"
Const DefaultDescription = "aqui sua descrição."
Const DefaultFirst200Chrs = "aqui a descrição de novo."				
Const strTopRatingConn = "PROVIDER=MICROSOFT.JET.OLEDB.4.0; DATA SOURCE=C:\seuPath\bd.mdb"

'
'	<!-- #include file="include-TopRating.asp" -->
'	<HTML>
'	<HEAD>
'	< % subGenerateMetaTag() % >
'	</HEAD>
'
'	<BODY>
'
'	< % subFirst200Chrs() % >
'
'	sua página aqui
'
'	</BODY>
'	</HTML>


Dim First200Chrs ' string

Sub subMetaTag()

Dim strSQL ' string
Dim objTopRatingCN ' connection
Dim objTopRatingRS ' recordset
Dim i 'as integer 

On error resume next

strSQL = "SELECT [Title],[Keywords],[Description],[First200Chrs]," & _
	 "(SELECT COUNT(MetaTagID) FROM [MetaTags]) AS lngCount " & _
	 "FROM [MetaTags] ORDER BY [MetaTagID] ASC"

Set objTopRatingCN = Server.CreateObject("ADODB.Connection")
Set objTopRatingRS = Server.CreateObject("ADODB.Recordset")

objTopRatingCN.Open strTopRatingConn

objTopRatingRS.Open strSQL, objTopRatingCN, 3, 1 '3 = OpenStatic, 1=ReadOnly

If not objTopRatingRS.EOF then
i = objTopRatingRS.Fields("lngCount")
'Go to a random record
Randomize
i = (int(Rnd * i))
If i > 0 then
	objTopRatingRS.PageSize = i
	objTopRatingRS.AbsolutePage = 2
End If
'Add the current MetaTag
Response.Write "<TITLE>" & objTopRatingRS.Fields("Title") & "</TITLE>" & vbcrlf & _
				"<META NAME=""Generator"" CONTENT=""EditPlus"">" & vbcrlf & _
				"<META NAME=""Author"" CONTENT=""José da Silva (www.seu_site.com)"">" & vbcrlf & _
				"<META NAME=""Keywords"" CONTENT=""" & objTopRatingRS.Fields("Keywords")  & """>" & vbcrlf & _
				"<META NAME=""Description"" CONTENT=""" & objTopRatingRS.Fields("Description")  & """>" & vbcrlf & _
				"<META NAME=""Robots"" CONTENT=""index,follow"">" & vbcrlf & _
				"<META NAME=""Revisit-after"" CONTENT=""30"">" & vbcrlf
'Store First200Chrs in variable
First200Chrs = objTopRatingRS.Fields("First200Chrs")
Else
Response.Write "<TITLE>" & DefaultTitle & "</TITLE>" & vbcrlf & _
				"<META NAME=""Generator"" CONTENT=""EditPlus"">" & vbcrlf & _
				"<META NAME=""Author"" CONTENT=""José da Silva (www.seu_site.com)"">" & vbcrlf & _
				"<META NAME=""Keywords"" CONTENT=""" & DefaultKeywords  & """>" & vbcrlf & _
				"<META NAME=""Description"" CONTENT=""" & DefaultDescription  & """>" & vbcrlf & _
				"<META NAME=""Robots"" CONTENT=""index,follow"">" & vbcrlf & _
				"<META NAME=""Revisit-after"" CONTENT=""30"">" & vbcrlf
'Store Default First200Chrs in variable
First200Chrs = DefaultFirst200Chrs
End If

'Close RS
objTopRatingRS.Close

'Close CN
objTopRatingCN.Close

'Clear Obj
Set objTopRatingRS = Nothing
Set objTopRatingCN = Nothing

'Trap Err
If Err then
Response.Write "<TITLE>" & DefaultTitle & "</TITLE>" & vbcrlf & _
				"<META NAME=""Generator"" CONTENT=""EditPlus"">" & vbcrlf & _
				"<META NAME=""Author"" CONTENT=""José da Silva (www.seu_site.com)"">" & vbcrlf & _
				"<META NAME=""Keywords"" CONTENT=""" & DefaultKeywords  & """>" & vbcrlf & _
				"<META NAME=""Description"" CONTENT=""" & DefaultDescription  & """>" & vbcrlf & _
				"<META NAME=""Robots"" CONTENT=""index,follow"">" & vbcrlf & _
				"<META NAME=""Revisit-after"" CONTENT=""30"">" & vbcrlf
'Store Default First200Chrs in variable
First200Chrs = DefaultFirst200Chrs
End If

End Sub


Sub subFirst200Chrs()

On error resume next

'ADD 200 CHRS IF ROBOT
If instr(1,Request.ServerVariables("HTTP_USER_AGENT"), "MSIE") > 0 then
If instr(1,ucase(Request.ServerVariables("HTTP_USER_AGENT")), "BOT") > 0 then
	Response.Write First200Chrs
End If
ElseIf instr(1,Request.ServerVariables("HTTP_USER_AGENT"), "Mac") > 0 then
If instr(1,ucase(Request.ServerVariables("HTTP_USER_AGENT")), "BOT") > 0 then
	Response.Write First200Chrs
End If
ElseIf instr(1,Request.ServerVariables("HTTP_USER_AGENT"), "Linux") > 0 then
If instr(1,ucase(Request.ServerVariables("HTTP_USER_AGENT")), "BOT") > 0 then
	Response.Write First200Chrs
End If
Else
Response.Write First200Chrs
End If

End Sub


Sub subGenerateMetaTag()

Dim Title 'as string
Dim Keywords 'as string
Dim Description 'as string

Dim strSQL 'as string
Dim objTopRatingCN 'as connection
Dim objTopRatingRS 'as recordset
Dim objTopRatingRS2 'as recordset

Dim arrFamilies 'as array
Dim i 'as integer

'On error resume next

Title = ""
Keywords = ""
Description = ""
First200Chrs = "" 'declared in page

strSQL = "SELECT [FamilyID] FROM [Families]"

Set objTopRatingCN = Server.CreateObject("ADODB.Connection")
Set objTopRatingRS = Server.CreateObject("ADODB.Recordset")
Set objTopRatingRS2 = Server.CreateObject("ADODB.Recordset")

objTopRatingCN.Open strTopRatingConn

objTopRatingRS.Open strSQL, objTopRatingCN, 3, 1 '0 = OpenStatic, 1=ReadOnly

If not objTopRatingRS.EOF then
'Convert recordset to array
arrFamilies = objTopRatingRS.GetRows()
'Randomize my array
arrFamilies = JumbleArray(arrFamilies)
For i = 0 to UBound(arrFamilies, 2)
	'Get a keyword for that family
	strSQL = "SELECT [Keyword] FROM [Keywords] WHERE [FamilyID]=" & arrFamilies(0,i)
	objTopRatingRS2.Open strSQL, objTopRatingCN, 3, 1 '3 = OpenStatic, 1=ReadOnly
	If not objTopRatingRS2.EOF then
		MoveRandom objTopRatingRS2
		Title = Title & objTopRatingRS2.Fields("Keyword") & " "
		Keywords = Keywords & objTopRatingRS2.Fields("Keyword") & ","
		Description = objTopRatingRS2.Fields("Keyword") & " " & Description
		First200Chrs = objTopRatingRS2.Fields("Keyword") & " " & First200Chrs & " " & objTopRatingRS2.Fields("Keyword")
	End If
	objTopRatingRS2.Close
Next
Response.Write "<TITLE>" & Title & "</TITLE>" & vbcrlf & _
				"<META NAME=""Generator"" CONTENT=""EditPlus"">" & vbcrlf & _
				"<META NAME=""Author"" CONTENT=""José da Silva (www.seu_site.com)"">" & vbcrlf & _
				"<META NAME=""Keywords"" CONTENT=""" & Keywords  & "TopRating"">" & vbcrlf & _
				"<META NAME=""Description"" CONTENT=""" & Description  & "TopRating"">" & vbcrlf & _
				"<META NAME=""Robots"" CONTENT=""index,follow"">" & vbcrlf & _
				"<META NAME=""Revisit-after"" CONTENT=""30"">" & vbcrlf
'Store Default First200Chrs in variable
First200Chrs = "<H1>" & Title & "</H1>" & vbcrlf & First200Chrs & " " & First200Chrs
Else
Response.Write "<TITLE>" & DefaultTitle & "</TITLE>" & vbcrlf & _
				"<META NAME=""Generator"" CONTENT=""EditPlus"">" & vbcrlf & _
				"<META NAME=""Author"" CONTENT=""José da Silva (www.seu_site.com)"">" & vbcrlf & _
				"<META NAME=""Keywords"" CONTENT=""" & DefaultKeywords  & """>" & vbcrlf & _
				"<META NAME=""Description"" CONTENT=""" & DefaultDescription  & """>" & vbcrlf & _
				"<META NAME=""Robots"" CONTENT=""index,follow"">" & vbcrlf & _
				"<META NAME=""Revisit-after"" CONTENT=""30"">" & vbcrlf
'Store Default First200Chrs in variable
First200Chrs = DefaultFirst200Chrs
End If

'Close RS
objTopRatingRS.Close

'Close CN
objTopRatingCN.Close

'Clear Obj
Set objTopRatingRS = Nothing
Set objTopRatingRS2 = Nothing
Set objTopRatingCN = Nothing

'Trap Err
If Err then
Response.Write "<TITLE>" & DefaultTitle & "</TITLE>" & vbcrlf & _
				"<META NAME=""Generator"" CONTENT=""EditPlus"">" & vbcrlf & _
				"<META NAME=""Author"" CONTENT=""José da Silva (www.seu_site.com)"">" & vbcrlf & _
				"<META NAME=""Keywords"" CONTENT=""" & DefaultKeywords  & """>" & vbcrlf & _
				"<META NAME=""Description"" CONTENT=""" & DefaultDescription  & """>" & vbcrlf & _
				"<META NAME=""Robots"" CONTENT=""index,follow"">" & vbcrlf & _
				"<META NAME=""Revisit-after"" CONTENT=""30"">" & vbcrlf
'Store Default First200Chrs in variable
First200Chrs = DefaultFirst200Chrs
End If

End Sub


Function MoveRandom(myRS)

Randomize Timer
myRS.MoveFirst
myRS.Move Int(RND*Cint(myRS.RecordCount))

End function


Function JumbleArray(ByVal aArray)

 Dim iUpper, iLower, iLoop, iSwapPos, varTmp

 iUpper = UBound(aArray, 2)
 iLower = LBound(aArray, 2)

 Randomize Timer

 For iLoop = iLower to iUpper

iSwapPos = Int(Rnd * (iUpper + 1))

   varTmp = aArray(0,iLoop)
   aArray(0,iLoop) = aArray(0,iSwapPos)
   aArray(0,iSwapPos) = varTmp

 Next

 JumbleArray = aArray

End Function

%>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Valeu galera...

 

resolvido.

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.