How to call things in {tags} like in a CMS in classic ASP

Hi Experts,

In PHP CMS kits i've seen code put in between brackets and the site then calls that specific feature. I think this would be a nice thing to add to my custom classic ASP CMS site. So for example i'd like to have CMS HTML content but the client could add {contactform} and the contact form would show there. How can this be done in classic ASP? Some example code would be ideal.

Thanks and happy 2012!

/ Tobzzz
LVL 11
tobzzzAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David Johnson, CD, MVPOwnerCommented:
You need to elaborate on your question. perhaps some pictures of what you have and what you want would be beneficial. As it stands we have really no idea of what you really are looking for.
0
neeraj523Commented:
Dear Tobzzz

this is a very common concept being used through industry giving ability to create mail merge type of feature. Here, through code, we replace a specifically formatted keyword (ie {FirstName} or ~FirstName~ etc) with a value coming from database or preconfigured in the code.

For example, a non technical user want to send an email to his clients added in db with a personalized message, he will have ability to create mail template using keyword like

Dear {FirstName} {LastName}

where in code, you can replace {FirstName} and {LastName} with the values from database for the target customers before actually sending the email.

Let me know if you need further specific help in this regard..

0
tobzzzAuthor Commented:
HI neeraj523,

Yes this is exactly what I want to do but I do not know how to code it. It is essentially a replace feature, as you say and it is replacing it with things from the database. Please advise on how to code it and if you have any code sample or site references that would really help!

Thanks!

/ Tobzzz
0
Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.

sammySeltzerCommented:
Actually, asp tags are more like <%fieldname%>

If you wish to learn asp, go here:

http://www.w3schools.com/asp/asp_examples.asp

0
nap0leonCommented:
Presume you have a webpage that says simply "Hello {Firstname} {Lastname}".
Let's also presume that you already know that you should replace {Firstname} with "John" and {Lastname} with "Smith". (Instead of names, you could be replacing {contactform} with HTML for a contact form, etc.)

<%
dim FirstName,LastName,PageText,outputText
FirstName = "John"
Lastname = "Smith" 
PageText = "Hello {firstname} {lastname},"
'PageText = "Hello <font color=red>{firstname} {lastname},</font>"

outputText = PageText
outputText = Replace(outputText,"{firstname}",FirstName)
outputText = Replace(outputText,"{lastname}",LastName)
%>
<html>
<body>
<h1><%=outputText%></h1>
</body>
</html>

Open in new window


In practice:
1- FirstName and LastName would be values you have to look up from somewhere.  Perhaps they are page level variables, or you fetch them from a database or querystring, etc.
2- PageText is the template text (or HTML: uncomment line 6 to verify that the HTMl you place in PageText is processed and not displayed as text)

Caution on #2: If you want to place large sections of HTML onto the page, it gets tricky... you need to make sure your template does not contain any single-doublequotes (e.g., <font color="red">) since that will break the ASP.  They need to be double-doublequotes (e.g., <font color=""red"">).
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
neeraj523Commented:
Dear Tobzzz

Does example given by nap0leon works for you ? DO you need further help on this question ?
0
tobzzzAuthor Commented:
Great example code - I will apply to the context of what I want to do with my new CMS - thanks nap0leon!

Also thanks to neeraj523 for the assist.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.