By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,822 Members | 729 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,822 IT Pros & Developers. It's quick & easy.

Help: Replacing string with template result

P: 1
Im new to Coldfusion, and here is what i would like to do:

I'm using a html-editor on one cfm-page, and saving the text in a database:

--mytext written i the html-editor ----------------------

Nunc libero ligula volutpat ac aliquet id laoreet ac lacus.


[peopleoutofoffice]


In dictum tincidunt turpis. Morbi sodales, justo ut posuere viverra
, mi turpis egestas nunc, ac consequat leo elit vitae pede.

---------------------------------------------------------

And showing the text entered in the editor on an other page.


Expand|Select|Wrap|Line Numbers
  1. <!-- viewcontent.cfm -->
  2.  
  3. <cfquery name="pagecontent" datasource="myDB">
  4.     Select id, mytext from contenttable
  5.     Where id = 5
  6. </cfquery>
  7.  
  8.  
  9. <cfoutput query="pagecontent">#mytext#</cfoutput>
  10.  
... that's very simple!


But, that i want to do is replacing the string; [peopleoutofoffice] in #mytest# with the result of an other cfm template, like this:


Expand|Select|Wrap|Line Numbers
  1. <CFOUTPUT>#replace(mytext,"[peopleoutofoffice]", GetOutOfOffice.cfm)#</CFOUTPUT>
  2.  
  3.  
  4. <!-- GetOutOfOffice.cfm -->
  5.  
  6. <cfquery name="OutOfOffice" datasource="myDB">
  7.     Select firstname, surname, status from persontable
  8.     Where status is "out"
  9. </cfquery>
  10.  
  11.  
  12. <table>
  13. <tr>
  14.     <td>The following people is out of office</td>
  15. </tr>
  16.  
  17. <cfoutput query="OutOfOffice">
  18. <tr>
  19.     <td>#firstname# #surname#</td>
  20. </tr>
  21. </cfoutput>
  22.  
  23. </table>
  24.  
----------------------------------------------------------

How do i solve this problem?
Dec 14 '07 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
Welcome to TSDN!

Interesting problem. I don't know if it's even possible, so how about setting a Coldfusion variable to the string within the template, including that template within the page and then using the variable instead of the template name in your replace function?
Dec 14 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.