Hi Bruce,

CFSILENT is a great tag IMO. It allows us to suppress all whitespace
generated within our custom tags, even when a custom tag is called from
within a CFOUTPUT block - if only Spectra (1.0) custom tags used CFSILENT...

Anyway, CFSILENT is like any other CF tag which has an opening and closing
tag - it must be closed on the same level as it was opened. Have a look
at your CFIFs, CFLOOPs, CFOUTPUTs, CFSWITCHs, etc. - they all close on the
same level as they were opened or the CF engine won't interpret the code.

The example you gave that doesn't work can be amended slightly such that
it does by simply closing the CFSILENT before you enter the CFIF block. It
can then be reopened as and when you need it to hide white space. One of the
techniques we use is to build all output in a variable then output it
after the closing CFSILENT at the end of the custom tag file. Alternatively,
when a custom tag has no content output but returns data we use error
handling tags like CFEXIT, CFTHROW, etc. to exit from the tag before we
reach the closing CFSILENT.

Your example could therefore be amended as follows (I'm asumming that you
want the "Some text" bits to be displayed to the user):

<CFSILENT>
<!--- CF code in here, maybe a load of variable set-up, querying,
        data processing, etc. Hide all of it in the output --->
</CFSILENT>
Some text
<CFIF ...>
        <CFSILENT>
        <CFSET ...>
        </CFSILENT>
    Some more text
</CFIF>

Alternatively, you could try this approach:

<CFSILENT>
<!--- CF code in here, maybe a load of variable set-up, querying,
        data processing, etc. Hide all of it in the output --->
<CFSET Variables.szText = "Some text">
<CFIF ...>
        <CFSET ...>
        <CFSET Variables.szText = Variables.szText
                & "Some more text">
</CFIF>
</CFSILENT>
<CFOUTPUT>#Variables.szText#</CFOUTPUT>

While the latter may look a bit unusual, on processing-heavy templates
it improves performance (straight from Macromedia Consulting).

Hope this helps. BTW, is the CF Language Reference really that lame?
I used to swear by it when I was learning ColdFusion.

Colin
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to