|
View:
New views
11 Messages
—
Rating Filter:
Alert me
|
|
|
cfmail custom tagHey all I'm trying to make a custom tag for cfmail so I can create a standard From, Subject, and HTML layout inside the email that is sent. I have created the tag and am using the open / close method, but the content of the email winds up being displayed on the page, as well as being emailed. I'm using THIS.generatedContent inside the custom tag in the body of the cfmail tag, and have even tried wrapping the tag inside a cfsilent. What am I missing? How do I stop the body of the custom tag from displaying, or is that not possible. Mik <cf_mailsend to="some@...">yadda yadda</cf_mailsend> ==== <cfsilent> <cfswitch expression="#thisTag.ExecutionMode#"> <cfcase value="start"> <cfparam name="attributes.to" default=""> </cfcase> <cfcase value="end"> <cfmail to="#trim(attributes.to)#" subject="subject" from="from@..." type="HTML"> <div style="padding:20px; margin:20px; border:2px solid blue;"> #trim(thistag.generatedcontent)# </div> </cfmail> </cfcase> </cfswitch> <cfsilent> -------- Michael Muller office (413) 863-6455 cell (413) 320-5336 skype: michaelBmuller http://MontagueWebWorks.com Information is not knowledge Knowlege is not wisdom Eschew Obfuscation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:328020 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4 |
|
|
Re: custom tag content displaying twiceHmm.... having never made a custom tag with an open and close pair, I didn't realize that the contained content will display twice. http://www.mail-archive.com/cf-talk@.../msg29687.html No way around this? It seems pretty stupid that CF wouldn't suppress the initial output, leaving the responsibility of displaying the content to the tag. Mik At 01:25 PM 11/4/2009, Michael Muller wrote: >Hey all > >I'm trying to make a custom tag for cfmail so I can create a standard From, Subject, and HTML layout inside the email that is sent. > >I have created the tag and am using the open / close method, but the content of the email winds up being displayed on the page, as well as being emailed. I'm using THIS.generatedContent inside the custom tag in the body of the cfmail tag, and have even tried wrapping the tag inside a cfsilent. > >What am I missing? How do I stop the body of the custom tag from displaying, or is that not possible. > >Mik > > ><cf_mailsend to="some@...">yadda yadda</cf_mailsend> > >==== > ><cfsilent> ><cfswitch expression="#thisTag.ExecutionMode#"> > ><cfcase value="start"> ><cfparam name="attributes.to" default=""> ></cfcase> > ><cfcase value="end"> ><cfmail to="#trim(attributes.to)#" subject="subject" from="from@..." type="HTML"> ><div style="padding:20px; margin:20px; border:2px solid blue;"> >#trim(thistag.generatedcontent)# ></div> ></cfmail> ></cfcase> > ></cfswitch> ><cfsilent> > > >-------- >Michael Muller >office (413) 863-6455 >cell (413) 320-5336 >skype: michaelBmuller >http://MontagueWebWorks.com > >Information is not knowledge >Knowlege is not wisdom > >Eschew Obfuscation > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:328038 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4 |
|
|
Re: custom tag content displaying twicejust do <cfset thisTag.generatedContent = "" /> in the end tag? CF has to do one or the other (render the output or suppress the output), and then provide a means to accomplish the other. At least from the perspective of the principle of least surprise, rendering the output seems like the correct default choice. cheers, barneyb On Wed, Nov 4, 2009 at 12:16 PM, Mik Muller <admin@...> wrote: > > Hmm.... having never made a custom tag with an open and close pair, I didn't realize that the contained content will display twice. > > http://www.mail-archive.com/cf-talk@.../msg29687.html > > No way around this? It seems pretty stupid that CF wouldn't suppress the initial output, leaving the responsibility of displaying the content to the tag. > > Mik > > > At 01:25 PM 11/4/2009, Michael Muller wrote: > >>Hey all >> >>I'm trying to make a custom tag for cfmail so I can create a standard From, Subject, and HTML layout inside the email that is sent. >> >>I have created the tag and am using the open / close method, but the content of the email winds up being displayed on the page, as well as being emailed. I'm using THIS.generatedContent inside the custom tag in the body of the cfmail tag, and have even tried wrapping the tag inside a cfsilent. >> >>What am I missing? How do I stop the body of the custom tag from displaying, or is that not possible. >> >>Mik >> >> >><cf_mailsend to="some@...">yadda yadda</cf_mailsend> >> >>==== >> >><cfsilent> >><cfswitch expression="#thisTag.ExecutionMode#"> >> >><cfcase value="start"> >><cfparam name="attributes.to" default=""> >></cfcase> >> >><cfcase value="end"> >><cfmail to="#trim(attributes.to)#" subject="subject" from="from@..." type="HTML"> >><div style="padding:20px; margin:20px; border:2px solid blue;"> >>#trim(thistag.generatedcontent)# >></div> >></cfmail> >></cfcase> >> >></cfswitch> >><cfsilent> >> >> >>-------- >>Michael Muller >>office (413) 863-6455 >>cell (413) 320-5336 >>skype: michaelBmuller >>http://MontagueWebWorks.com >> >>Information is not knowledge >>Knowlege is not wisdom >> >>Eschew Obfuscation >> >> >> > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:328041 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4 |
|
|
Re: custom tag content displaying twiceThere is a way to suppress that and I can't recall how (been a long time). I see in my head something to do with... <cfif THIS.tagStart> and <cfif THIS.tagEnd> HTH...at least you know it is possible....now go forth and Google ;-) Cheers - Bryan Stevenson B.Comm. VP & Director of E-Commerce Development Electric Edge Systems Group Inc. phone: 250.480.0642 fax: 250.480.1264 cell: 250.920.8830 e-mail: bryan@... web: www.electricedgesystems.com Notice: This message, including any attachments, is confidential and may contain information that is privileged or exempt from disclosure. It is intended only for the person to whom it is addressed unless expressly authorized otherwise by the sender. If you are not an authorized recipient, please notify the sender immediately and permanently destroy all copies of this message and attachments. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:328042 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4 |
|
|
Re: custom tag content displaying twiceBarney, Well, as I said, in this case the prinicple of least surprise would have effused a behavior wherein the page calling the custom tag would not have rendered the content, leaving that responsibility to the tag itself. In _my_ mind, anyway. I mean, if the tag is supposed to receive the content, the calling page really has no business rendering the content again. And not being able to stop it from being rendered again is a serious drawback. I mean, think of the lowly EM tag. It takes the input and renders the content in italics (or whatever). The browser doesn't then render the content again UNitalicized, correct? It trusts the EM tag to take care of its business. Isn't that the way a tag should work? I'll try your suggestion, below, but I've already gone the less elegant route of using cfsavecontent around my content and pushing the resulting variable as an attribute into the now-self-closing custom tag. Mik At 03:23 PM 11/4/2009, Barney Boisvert wrote: >just do <cfset thisTag.generatedContent = "" /> in the end tag? > >CF has to do one or the other (render the output or suppress the >output), and then provide a means to accomplish the other. At least >from the perspective of the principle of least surprise, rendering the >output seems like the correct default choice. > >cheers, >barneyb > >On Wed, Nov 4, 2009 at 12:16 PM, Mik Muller <admin@...> wrote: >> >> Hmm.... having never made a custom tag with an open and close pair, I didn't realize that the contained content will display twice. >> >> http://www.mail-archive.com/cf-talk@.../msg29687.html >> >> No way around this? It seems pretty stupid that CF wouldn't suppress the initial output, leaving the responsibility of displaying the content to the tag. >> >> Mik >> >> >> At 01:25 PM 11/4/2009, Michael Muller wrote: >> >>>Hey all >>> >>>I'm trying to make a custom tag for cfmail so I can create a standard From, Subject, and HTML layout inside the email that is sent. >>> >>>I have created the tag and am using the open / close method, but the content of the email winds up being displayed on the page, as well as being emailed. I'm using THIS.generatedContent inside the custom tag in the body of the cfmail tag, and have even tried wrapping the tag inside a cfsilent. >>> >>>What am I missing? How do I stop the body of the custom tag from displaying, or is that not possible. >>> >>>Mik >>> >>> >>><cf_mailsend to="some@...">yadda yadda</cf_mailsend> >>> >>>==== >>> >>><cfsilent> >>><cfswitch expression="#thisTag.ExecutionMode#"> >>> >>><cfcase value="start"> >>><cfparam name="attributes.to" default=""> >>></cfcase> >>> >>><cfcase value="end"> >>><cfmail to="#trim(attributes.to)#" subject="subject" from="from@..." type="HTML"> >>><div style="padding:20px; margin:20px; border:2px solid blue;"> >>>#trim(thistag.generatedcontent)# >>></div> >>></cfmail> >>></cfcase> >>> >>></cfswitch> >>><cfsilent> >>> >>> >>>-------- >>>Michael Muller >>>office (413) 863-6455 >>>cell (413) 320-5336 >>>skype: michaelBmuller >>>http://MontagueWebWorks.com >>> >>>Information is not knowledge >>>Knowlege is not wisdom >>> >>>Eschew Obfuscation >>> >>> >>> >> >> > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:328049 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4 |
|
|
Re: cfmail custom tagI didn't test it, but try something like: <cfsilent> <!--- No need for an end tag ---> <cfif NOT compareNoCase(thisTag.executionMode, "end")> <cfexit method="exitTag"> </cfif> <!--- Required attributes ---> <cfparam name="attributes.to"> <!--- Default attributes ---> <cfparam name="attributes.from" default="from@..."> <cfparam name="attributes.subject" default="Default Subject"> <cfparam name="attributes.type" default="HTML"> <!--- Send email ---> <!--- CF 8 or later version could be: <cfmail attributeCollection="#attributes#"> ---> <cfmail from="#attributes.from#" to="#trim(attributes.to)#" subject="#attributes.subject#" type="#attributes.type#"> <div style="padding:20px; margin:20px; border:2px solid blue;"> #trim(thisTag.generatedContent)# </div> </cfmail> <!--- Kill the output ---> <cfset thisTag.generatedContent = ""> </cfsilent> -- Brad Roberts AgentBlaze, LLC Office: (865) 681-8390 Fax: (866) 583-9334 brad@... http://www.agentblaze.com On Wed, Nov 4, 2009 at 1:25 PM, Michael Muller <michael@...>wrote: > > Hey all > > I'm trying to make a custom tag for cfmail so I can create a standard From, > Subject, and HTML layout inside the email that is sent. > > I have created the tag and am using the open / close method, but the > content of the email winds up being displayed on the page, as well as being > emailed. I'm using THIS.generatedContent inside the custom tag in the body > of the cfmail tag, and have even tried wrapping the tag inside a cfsilent. > > What am I missing? How do I stop the body of the custom tag from > displaying, or is that not possible. > > Mik > > > <cf_mailsend to="some@...">yadda yadda</cf_mailsend> > > ==== > > <cfsilent> > <cfswitch expression="#thisTag.ExecutionMode#"> > > <cfcase value="start"> > <cfparam name="attributes.to" default=""> > </cfcase> > > <cfcase value="end"> > <cfmail to="#trim(attributes.to)#" subject="subject" from=" > from@..." type="HTML"> > <div style="padding:20px; margin:20px; border:2px solid blue;"> > #trim(thistag.generatedcontent)# > </div> > </cfmail> > </cfcase> > > </cfswitch> > <cfsilent> > > > -------- > Michael Muller > office (413) 863-6455 > cell (413) 320-5336 > skype: michaelBmuller > http://MontagueWebWorks.com > > Information is not knowledge > Knowlege is not wisdom > > Eschew Obfuscation > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:328050 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4 |
|
|
Re: custom tag content displaying twiceThe custom tag isn't rendering the content again, YOU are rendering the content again. If you create an empty custom tag and invoke it, you'll get a single copy of the output. If you then add emitting of the generated content in the custom tag, you'll get two copies. So building up from the "nothing" case, you can see that you should expect double output if you're doing outputting explicitly. The EM tag in HTML is rather different, because it's being interpreted as a formatting directive, not executed as code. A better example would be CFQUERY, where the generated content (the SQL statement) is not emitted to the page output. If you were to reimplement a simplistic CFQUERY, it might look like this (using some "magic" helper functions for brevity): <cfif thisTag.executionMode EQ "start"> <cfparam name="attributes.dsn" default="#application.dsn#" /> <cfelse> <cfset sql = thisTag.generatedContent /> <cfset thisTag.generatedContent = "" /> <!--- we don't want the SQL emitted ---> <cfset result = runQueryOnDsn(attributes.dsn, sql) /> <cfif structKeyExists(attributes, "name")> <cfset caller[attributes.name] = result /> </cfif> </cfif> cheers, barneyb On Wed, Nov 4, 2009 at 2:06 PM, Mik Muller <admin@...> wrote: > > Barney, > > Well, as I said, in this case the prinicple of least surprise would have effused a behavior wherein the page calling the custom tag would not have rendered the content, leaving that responsibility to the tag itself. In _my_ mind, anyway. I mean, if the tag is supposed to receive the content, the calling page really has no business rendering the content again. > > And not being able to stop it from being rendered again is a serious drawback. I mean, think of the lowly EM tag. It takes the input and renders the content in italics (or whatever). The browser doesn't then render the content again UNitalicized, correct? It trusts the EM tag to take care of its business. Isn't that the way a tag should work? > > I'll try your suggestion, below, but I've already gone the less elegant route of using cfsavecontent around my content and pushing the resulting variable as an attribute into the now-self-closing custom tag. > > Mik > -- Barney Boisvert bboisvert@... http://www.barneyb.co ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:328053 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4 |
|
|
Re: custom tag content displaying twiceI'm not sure why it does that but there is an easy way to avoid it. That is not to close the tag properly in XHTML style, just use ">" instead of "/>": This will give you double output: <cf_mytag /> This will give you single output (more expected result)" <cf_mytag> I think that is because the first case is equivalent to <cf_mytag></cf_mytag> and this triggers coldfusion to execute the script twice. Khoa >There is a way to suppress that and I can't recall how (been a long >time). > >I see in my head something to do with... > ><cfif THIS.tagStart> > >and > ><cfif THIS.tagEnd> > >HTH...at least you know it is possible....now go forth and Google ;-) > >Cheers >- > >Bryan Stevenson B.Comm. >VP & Director of E-Commerce Development >Electric Edge Systems Group Inc. >phone: 250.480.0642 >fax: 250.480.1264 >cell: 250.920.8830 >e-mail: bryan@... >web: www.electricedgesystems.com > >Notice: >This message, including any attachments, is confidential and may contain >information that is privileged or exempt from disclosure. It is intended >only for the person to whom it is addressed unless expressly authorized >otherwise by the sender. If you are not an authorized recipient, please >notify the sender immediately and permanently destroy all copies of this >message and attachments. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:328080 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4 |
|
|
RE: custom tag content displaying twiceGoogle: thistag.executionmode and thistag.generatedcontent thistag.executionmode determines which tag (opening/closing) is being executed at the time. thistag.generatedcontent contains the code that you have wrapped with the custom tag's tags. It can be set = "" to eliminate duplicate output. Thanks, Mike -----Original Message----- From: Vinh Khoa Nguyen [mailto:nvkhoatv@...] Sent: Thursday, November 05, 2009 11:57 PM To: cf-talk Subject: Re: custom tag content displaying twice I'm not sure why it does that but there is an easy way to avoid it. That is not to close the tag properly in XHTML style, just use ">" instead of "/>": This will give you double output: <cf_mytag /> This will give you single output (more expected result)" <cf_mytag> I think that is because the first case is equivalent to <cf_mytag></cf_mytag> and this triggers coldfusion to execute the script twice. Khoa >There is a way to suppress that and I can't recall how (been a long >time). > >I see in my head something to do with... > ><cfif THIS.tagStart> > >and > ><cfif THIS.tagEnd> > >HTH...at least you know it is possible....now go forth and Google ;-) > >Cheers >- > >Bryan Stevenson B.Comm. >VP & Director of E-Commerce Development Electric Edge Systems Group >Inc. >phone: 250.480.0642 >fax: 250.480.1264 >cell: 250.920.8830 >e-mail: bryan@... >web: www.electricedgesystems.com > >Notice: >This message, including any attachments, is confidential and may >contain information that is privileged or exempt from disclosure. It is >intended only for the person to whom it is addressed unless expressly >authorized otherwise by the sender. If you are not an authorized >recipient, please notify the sender immediately and permanently destroy >all copies of this message and attachments. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:328093 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4 |
|
|
Re: custom tag content displaying twiceI think it was mentioned earlier in the thread, but if you want to prevent a custom tag from running twice when using <cf_foo></cf_foo> or <cf_foo /> syntax, just add one line of code to the end: <cfexit method="exitTag"> On Thu, Nov 5, 2009 at 11:57 PM, Vinh Khoa Nguyen <nvkhoatv@...> wrote: > > I'm not sure why it does that but there is an easy way to avoid it. That is not to close the tag properly in XHTML style, just use ">" instead of "/>": > > This will give you double output: > > <cf_mytag /> > > This will give you single output (more expected result)" > > <cf_mytag> > > I think that is because the first case is equivalent to <cf_mytag></cf_mytag> and this triggers coldfusion to execute the script twice. > > Khoa > >>There is a way to suppress that and I can't recall how (been a long >>time). >> >>I see in my head something to do with... >> >><cfif THIS.tagStart> >> >>and >> >><cfif THIS.tagEnd> >> >>HTH...at least you know it is possible....now go forth and Google ;-) >> >>Cheers >>- >> >>Bryan Stevenson B.Comm. >>VP & Director of E-Commerce Development >>Electric Edge Systems Group Inc. >>phone: 250.480.0642 >>fax: 250.480.1264 >>cell: 250.920.8830 >>e-mail: bryan@... >>web: www.electricedgesystems.com >> >>Notice: >>This message, including any attachments, is confidential and may contain >>information that is privileged or exempt from disclosure. It is intended >>only for the person to whom it is addressed unless expressly authorized >>otherwise by the sender. If you are not an authorized recipient, please >>notify the sender immediately and permanently destroy all copies of this >>message and attachments. > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:328096 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4 |
|
|
Re: custom tag content displaying twiceDon't forget thisTag.hasEndTag so you can tell if you're going to get a thisTag.executionMode EQ "end" invocation or not. On Fri, Nov 6, 2009 at 7:28 AM, Dawson, Michael <md40@...> wrote: > > Google: thistag.executionmode and thistag.generatedcontent > > thistag.executionmode determines which tag (opening/closing) is being > executed at the time. > > thistag.generatedcontent contains the code that you have wrapped with > the custom tag's tags. It can be set = "" to eliminate duplicate > output. > > Thanks, > Mike > -- Barney Boisvert bboisvert@... http://www.barneyb.co ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:328095 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4 |
| Free embeddable forum powered by Nabble | Forum Help |