Last updated:

Get Your Site Submitted for Free in the World's Largest B2B Directory!

Email Address:
* URL:
*
*Indicates Mandatory Field

Terms & Conditions

DevWebProBR
FlashNewz
DevWebPro





Coldfusion: Using CFTREE For Navigation

By Raymond Camden
Expert Author
Article Date: 2007-07-31

A user on cf-talk today asked if it was possible to use ColdFusion 8's new HTML CFTREE as a navigation tool.

Turns out it is rather simple, and like most things in ColdFusion, there are multiple solutions.

First off - when you use the HREF attribute of CFTREEITEM, you are allowed to use JavaScript. One simple solution would be to just do:

<cftreeitem display="products" href="javaScript:doProducts('...')">

You could use document.href.location to move the entire page, or use the new ColdFusion.navigate function to load a URL into a UI item like a CFDIV or CFWINDOW.

While that works ok for static, hard coded trees, it isn't a good solution for dynamic trees, and, it can be done simpler if you just bindings. Consider this example:

<cfform name="form">

<cftree format="html" name="mytree">
   <cftreeitem display="Navigation" value="root">
   <cftreeitem display="Page A" parent="root" value="a">
   <cftreeitem display="Page B" parent="root" value="b">
</cftree>
</cfform>

<cfdiv bind="url:content.cfm?value={mytree.node}" />


I've built a simple tree with one main node and two child nodes. I then added a CFDIV that is bound to the tree.

When binding to a tree, you can get two values: node and path. Node returns just the value for the selected item.

Path returns the path of the node itself. Thanks to Todd Sharp for finding these values in the docs.

p.s. As a side question - who would like to see an API doc that covers stuff like this?

I wasn't able to find it in the reference and it was hard to find in the developers guide.

I'd like a guide that more clearly describes working with ColdFusion's new UI elements.

Comments


About the Author:
Raymond Camden, ray@camdenfamily.com
http://ray.camdenfamily.com

Raymond Camden is Vice President of Technology for roundpeg, Inc. A long time ColdFusion user, Raymond has worked on numerous ColdFusion books and is the creator of many of the most popular ColdFusion community web sites. He is an Adobe Community Expert, user group manager, and the proud father of three little bundles of joy.


Newsletter Archive | Article Archive | Submit Article | Advertising Information | About Us | Contact

DevWebProBrazil is an iEntry.com publication
© iEntry Inc. All Rights Reserved Privacy Policy Legal

Click Here to Return to the Home Page