Connecting Tech Pros Worldwide Help | Site Map

Help: Replacing string with template result

Newbie
 
Join Date: Dec 2007
Posts: 1
#1: Dec 14 '07
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?
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#2: Dec 14 '07

re: Help: Replacing string with template result


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?
Reply