Solved

Using Curly Brakets To Represent Code Snippets

Posted on 2009-05-07
2
366 Views
Last Modified: 2012-05-06
Not sure if im going to be able to accomplish this but here goes anyway..

at the minute i have a rich text editor which allows users to type in text and bold, italic, colour etc and they they click the save button it posts to a script which then takes the HTML output from the rich text editor and saves the HTML to a field in the DB, a basic CMS system for content on a web page.

My question is this...

When i output the html on a display webpage (not in the rich text editor) i basically just fetch a recordset for that page and Response.Write the HTML field to the browser.

i would like to be able to define some fixed commands within the HTML such as:

{CustomerFirstName}
{CustomerLastName}
{CustomerAddress}

The idea is that if someone was typing into the rich text editor a sentence and they wanted to include a dynamic value into a certain place they would just create the sentence as such:

Dear {CustomerFirstname} {CustomerLastname},

Thank you for your order, it will be dispatached soon to your home address of:
{CustomerAddress}

When the customer webpage is run and it puls the HTML from the DB, it recognises the fixed command and inserts the correct value - basically like a mail merge in word.

Does anyone have an ideas of how to acomplish this as simply as possible?

Thans,
Carl
0
Comment
Question by:net-workx
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
Bobaran98 earned 500 total points
ID: 24332328
Sure, this should be pretty easy.  I'm assuming you can query your DB and generate a string variable with the HTML code, and that you can also get your replacement values into string variables to.  Building on that, check out my code below:

Dim htmlFromDB as String
Dim fNameReplace as String
Dim lNameReplace as String
Dim addressReplace as String
 
'insert code here for assigning
'  values to above variables
 
Dim newHtml as String
 
newHtml = Replace(htmlFromDB, "{CustomerFirstname}", fNameReplace)
newHtml = Replace(newHtml, "{CustomerLastname}", lNameReplace)
newHtml = Replace(newHtml, "{CustomerAddress}", addressReplace)

Open in new window

0
 

Author Comment

by:net-workx
ID: 24336368
Excellent!

I didnt even think about doing it that way... things are so simple when you have someone else look at them!

Final code attached below for future use.  I can now add more fixed code snippets to whenever i want.

Thanks for your prompt solution to this question!

Carl
emailBody = RSemail("txtOrderReceivedBody")
emailBody = Replace(emailBody, "{FirstName}", txtFirstName)
emailBody = Replace(emailBody, "{LastName}", txtLastName)
emailBody = Replace(emailBody, "{OrderNumber}", intOrderID)
emailBody = Replace(emailBody, "{WebsiteAddress}", strWebAddress)
emailBody = Replace(emailBody, "{CompanyName}", strCompanyName)
emailBody = Replace(emailBody, "{Logo}", "<img src=""" & strWebAddress & strLogo & """>")

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
T-sql Date Format 9 67
Display SQL maintenance plan SQL Code 3 47
Presenting my portfolio on the web? 11 53
Access 2003, find all instances of database ODBC 3 52
Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question