Embedding URLs in a cftree tag

The href attribute in the cftreeitem tag lets you designate tree items as links. To use this feature in a cftree control, you define the destination of the link in the href attribute of the cftreeitem tag. The URL for the link can be a relative URL or an absolute URL, as in the following examples.

To embed links in a cftree control:

  1. Create a ColdFusion page named tree3.cfm with the following contents:
    <cfform action="submit.cfm">
    <cftree name="oak"
    	highlighthref="Yes"
    	height="100"
    	width="200"
    	hspace="100"
    	vspace="6"
    	hscroll="No"
    	vscroll="No"
    	border="No">
    	<cftreeitem value="Important Links">
    	<cftreeitem value="Macromedia Home"
    		parent="Important Links"
    		img="document"
    		href="http://www.macromedia.com">
    	<cftreeitem value="ColdFusion Developer Center"
    		parent="Important Links"
    		img="document"
    		href="http://www.macromedia.com/devnet/mx/coldfusion/">
    </cftree>
    </cfform>
    
  2. Save the page and view it in your browser.

    The following figure shows the output of this code:


    Embedded links in a tree control

Reviewing the code

The following table describes the highlighted code and its function:

Code Description
href="http://www.macromedia.com">

Makes the node of the tree a link.

href="http://www.
macromedia.com/devnet/mx/coldfusion/">

Makes the node of the tree a link.

Although this example does not show it, the href attribute can refer to the name of a column in a query if that query populates the tree item.


View comments in LiveDocs