PDA

View Full Version : Help with templates..


gRoberts
03-31-05, 11:25
Hey peeps, i've created a template system, ( or should I say is currently being created ) and I need to be able to convert text into links, but this needs to be on the fly.

so I need to turn home into <a href="http://www.eycdwebdesign.co.uk">Home</a>

What I have is 3 pages so far,

default.asp
subs.inc
generic_header.asp

default.asp contains a caller for a sub which is contained in subs.inc
subs.inc contains the following coding:


<%

BaseHREF = "http://localhost/root3/"

sub welcome_banner()

dayname = day(now)
monthlyname = monthname(month(now))

if dayname = "1" or dayname = "21" or dayname = "31" then

dayname = dayname & "<img src='../../images/Template_General/shim.gif' alt='dateprefix' width='2' align='top'><img src='../../images/Template_General/dateprefix-sst.gif' alt='dateprefix' align='top'> "

elseif dayname = "2" or dayname = "22" then

dayname = dayname & "<img src='../../images/Template_General/shim.gif' alt='dateprefix' width='2' align='top'><img src='../../images/Template_General/dateprefix-nd.gif' alt='dateprefix' align='top'> "

elseif dayname = "3" or dayname = "23" then

dayname = dayname & "<img src='../../images/Template_General/shim.gif' alt='dateprefix' width='2' align='top'><img src='../../images/Template_General/dateprefix-rd.gif' alt='dateprefix' align='top'> "

else

dayname = dayname & "<img src='../../images/Template_General/shim.gif' alt='dateprefix' width='2' align='top'><img src='../../images/Template_General/dateprefix-fx.gif' alt='dateprefix' align='top'> "

end if

if len(monthlyname) > 5 then

monthlyname = monthlyname & left(monthlyname, 5)

end if

if session("userhash") <> "" then

response.write "Welcome User"

else

response.write(weekdayname(weekday(now)) & " " & dayname & " " & monthlyname & " " & year(now))

end if

end sub

function Linkme(strlink)

set objRegExp= new Regexp
objRegExp.pattern = "\[LINK\]((.|\n)*?)\[\/LINK\]"
strlink=objRegExp.replace (strlink, "<a href="" $1 "">$1</a>")
objRegExp.Global=true
objRegExp.Ignorecase=true
linkme=strlink

end function

sub pull_template(file)

dim grab_template
set grab_template = server.createobject("Microsoft.XMLHTTP")
if inStr(file, "http://") then

grab_template.Open "GET", file, false

else

grab_template.Open "GET", BaseHREF & file, false

end if

grab_template.Send

template_info = grab_template.responseText

if inStr(file, "http://") then

template_info = Linkme(template_info)
template_info = replace(template_info, "images/", file & "/images/")
template_info = replace(template_info, "files/", file & "/files/")
template_info = replace(template_info, "background-color: #262A32;", "background-color: #FFFFFF;")
template_info = replace(template_info, "background-color: #730000;", "background-color: #FFFFFF;")
else

template_info = Linkme(template_info)
template_info = replace(template_info, "../../", BaseHREF)
template_info = replace(template_info, "", "")

end if

response.write template_info

set grab_template = nothing

end sub
%>


This script pulls in generic_header.asp and then replaces certain things through out the script. What I need to be able to do is change certain things on the fly.

so if the template contains home then change it into <a href="http://www.eycdwebdesign.co.uk">Home</a>.

Hope someone can help?

TIA

Gav

Easist way to show you what I am doing is to attach the files, in subs.inc you will need to change the variable BaseHREF to what ever the location you have given it.

Cheers