FarCry: Know your tag libraries intimately

In a comment to yesterdays post about the skin:buildLink tag Jack is asking;

What about parameters?

If we have parameters on link such as &pagename=123&language=en_us

Now that is a good question, and David makes a good answer to that in a follow up coment.

The buildLink tags also takes a few nice args that let you manage other params etc.

* The stParameters arg will allow you to supply a struct that will be used to create the extra URL params * Also the xCode arg will let you add other attributes to the (a) link tag (good for titles etc).

But how do you learn about this? Where do you go to find out what parameters a tag can take? I find that the easiest is to go straight to the code in the core. For example, if you open the file core/tags/webskin/buildLink.cfm file you'll see the following (abreviated):

<!---
|| ATTRIBUTES ||
$in: objectid -- navigation obj id$
$in: title -- link text $
$in: external -- external link for nav node $
$in: class -- css class for link$
$in: target -- target window for link$
$in: xCode -- eXtra code to be placed inside the anchor tag
--->

<cfif thistag.executionMode eq "Start">
   <cfparam name="attributes.linktext" default="">
   <cfparam name="attributes.target" default="_self">
   <cfparam name="attributes.bShowTarget" default="false">
   <cfparam name="attributes.externallink" default="">
   <cfparam name="attributes.id" default="">
   <cfparam name="attributes.class" default="">
   <cfparam name="attributes.urlOnly" default="false">
   <cfparam name="attributes.r_url" default="">
   <cfparam name="attributes.xCode" default="">
   <cfparam name="attributes.includeDomain" default="false">
   <cfparam name="attributes.stParameters" default="#StructNew()#">
   <cfparam name="attributes.JSWindow" default="0"><!--- Default to not using a Javascript Window popup --->
   <cfparam name="attributes.stJSParameters" default="#StructNew()#">

Some of the attributes the tag can take are explained in the comments to the tag, but not all. But looking at the cfparams you get a pretty good overview over what attributes you can use. Ok - it's not totally intuitive what they all do, but getting to know the attributes you can use and what they do plays a big part in using the tag libraries succesfully.

Happy FarCry'ing

Comments