Adobe ColdFusion 8

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.

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="Adobe Home"
            parent="Important Links"
            img="document"
            href="http://www.adobe.com">
        <cftreeitem value="ColdFusion Developer Center"
            parent="Important Links"
            img="document"
            href="http://www.adobe.com/devnet/coldfusion/">
    </cftree>
    </cfform>
    

  2. Save the page and view it in your browser.

    The following image shows the output of this code:

Reviewing the code

The following table describes the highlighted code and its function:

Code

Description

href="http://www.adobe.com">

Makes the node of the tree a link.

href="http://www. adobe.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.