[thelist] CF: form. Url. Attributes. A better way?

jeff jeff at members.evolt.org
Mon Jan 15 00:13:31 CST 2001


frank & jon,

:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: From: Jon Hall
:
: If you call your query that you want to modularize
: into a custom tag but your id variable comes to
: each page a different way, all you have to do is
: set the id to request.id and it will be available
: throughout any custom tags in that request.  If
: you intend to start using custom tags a lot, the
: request scope is invaluable.
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

be very careful and think long and hard before you consider using the
request scope, especially with such generic variable names as "id".  if
you're calling a custom tag or cfmodule and you need to make some data
available to it, pass it in with an attribute.  the custom tag or cfmodule
template should *never* assume what variables are available to it from the
outside.  what's more, a custom tag should not attempt to change the values
of variables outside of the custom tag, especially those in the request
scope, if at all possible.

the problem (which sometimes seems like an advantage) with the request scope
is that it's a global scope meaning anything in that scope is available to
*everything* from the beginning of the request, through the processing of
all templates and custom tags, until the end of the request.  at first this
seems like a good thing.  however, using it within custom tags tends to make
them much less modular and much more dependent on certain variables being
setup outside of the custom tag.

good luck,

.jeff

name://jeff.howden
game://web.development
http://www.evolt.org/
mailto:jeff at members.evolt.org





More information about the thelist mailing list