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
Solved

Using Curly Brakets To Represent Code Snippets

Posted on 2009-05-07
2
363 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
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Create an automated page index 9 50
query question 12 32
Current Month Filter in Visual Studio 10 22
Programming Language for Wordpress 7 36
Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

856 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