Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Custom Tags

Status
Not open for further replies.

iamkillyou

Programmer
Jul 12, 2001
30
US
I have a custom tag that draws a window frame around content, and a tag-calling-tag that calls it, both tags use cfswitch to test if we're in a start tag or an end tag. I'm having problems grasping how to stick an end tag in my tag calling tag.

<!--- CallWidget.cfm
--->
<!--- Params etc omitted --->
<CFSWITCH expression=#ThisTag.ExecutionMode#>
<CFCASE value='start'>
<CF_WIDGET AttributeCollection=<CFOUTPUT>&quot;#WindowParams#&quot;</CFOUTPUT>>
</CFCASE>

<CFCASE value='end'>
<!--- Ending the custom tag here is causing a cf error but it's the only way(that I know of) to encapsulate the data around the caller to CallTag.cfm --->
</CF_WIDGET>
</CFCASE>
</CFSWITCH>

This is the test document that calls the tag calling tag.

<!--- Test.cfm
--->
<CF_CALLWIDGET TITLE =&quot;Title&quot;
HEIGHT =&quot;100&quot;
PIXELWIDTH =&quot;400&quot;
HEADER =&quot;Header&quot;>
Test text goes here
</CF_CALLWIDGET>

 
It would help to know the error you're getting, but from looking at what code you have here, it seems that maybe it's a recursion problem.

You must be careful with recursion and make sure that your flow is correct. ie every time execution &quot;jumps&quot; and continues in a different instance of that very same file (with whatever parameters), the execution will always jump back and continue from where it jumped from.

HTH,
Marc
 
In CallWidget.cfm:
it doesn't like the end tag </CF_WIDGET>
 
The problem is that ColdFusion is trying to execute the tags that you simply want to be part of the produced output.

So CF thinks you have a starting tag <cf_widget> and an ending tag </cf_widget> separated by flow of control statements (the case tags) with improper nesting. It's real confused.

I'm not sure how you're going to get around it. You can get the tag in place by putting the string &quot;</cf_widget>&quot; in a variable:

Code:
<cfset closeWidget = &quot;</cf_widget>&quot;>

then using pound signs in the case statement:

Code:
#closeWidget#

but if you want the code to execute, it gets a lot more complicated. In a similar situation, I've built up a varibale with all the code, written to a file, and CFINCLUDEd it in another template. Painful.
 
My tag does require a end tag I'm drawing a gui-like window around content, and the in start mode it does a complex table up until a <TD>

and in the end mode it finishes the window </TD>

so anything between the tag call--

<CF_CALLWIDGET>

content goes here

</CF_CALLWIDGET>

--ends up in the window, I've since found a work around.

Heres what I'm doing:

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top