Iain Urquhart

Taxonomy

taxonomy:get_node

Introduced in Taxonomy v2.1, this tag returns information about a single node, and optionally it's parent

{exp:taxonomy:get_node tree_id="1" key="entry_id" val="{entry_id}"}
	<p>This node is {node_level} levels deep!</p>
{/exp:taxonomy:get_node}

Tag Parameters

tree_id=

tree_id="1"

The id of the tree which contains the node want to fetch. This is a required parameter.


key=

key="entry_id"

The key value which you'd like to use to select the node. This is a required parameter.


val=

val="entry_id"

The value of the above key which you'd like use to to select the node. This is a required parameter.


var_prefix=

var_prefix="tx_"

Prefix variables to avoid conflicts with other tag variables


include_parent=

include_parent="yes"

Makes an additional set of variables available which return data about the parent node as well as the current node. (In addition to the variables below, you'll get another duplicate set which are available with a parent_ prefix that return data about the node's parent.)


Tag Variables

These varables are available between the tag pair

Variable Example Output / Notes
{node_id} 22
The ID for this node
{node_lft} 1
The lft value for this node
{node_rgt} 2
The rgt value for this node
{node_label} About Us
The label for this node
{node_entry_id} 16
The entry_id of the entry associated with this node
{node_status} open
The status of the entry associated with this node
{node_highlight} ffffff
The hex of the entry status associated with this node
{node_title} About Us
The title of the entry associated with this node
{node_url_title} about_us
The url_title of the entry associated with this node
{node_entry_date} 1310087884
The entry_date timestamp of the entry associated with this node
{node_template_id} 12
The template id of the node's selected template
{node_group_id} 1
The template group id associated with this node
{node_template_name} entry
The template name associated with this node
{node_group_name} blog
The template group name associated with this node
{node_is_site_default} y
returns y if the template group associated with this node is the site default
{node_level} 2
returns the depth of this node (0 is root)
{node_level+1} 3
returns the depth of this node + 1
{node_level+2} 4
returns the depth of this node + 2
{node_level-1} 1
returns the depth of this node - 1
{node_level-2} 0
returns the depth of this node - 2
{node_has_children} yes
returns 'yes' if the node has children

Note: if you've used the include_parent="yes" parameter, all the above variables are available with a parent_ prefix, for example parent_node_level will return the depth of the node's parent.


Examples

Setting the active_branch_start_level parameter on a taxonomy:nav tag dynamically by using the current node's parent's depth

{exp:taxonomy:get_node 
    tree_id
="1"
    
key="entry_id" 
    
val="{entry_id}"
    
var_prefix="tx_"
    
include_parent="yes"
}
    
<fieldset>
        <
legend>Node information</legend>
            
        <
p>This node is {tx_node_level} levels deep.</p>
        <
p>The parent node is {tx_parent_node_level} levels deep. </p>
        <
p>The url to the parent is {exp:taxonomy:node_url entry_id="{tx_parent_node_entry_id}" tree_id="1"}</p>
    
        
{exp:taxonomy:nav 
            tree_id
="1" 
            
entry_id="{entry_id}" 
            
active_branch_start_level="{tx_parent_node_level}"
            
display_root="no"
            
auto_expand="yes"
        
}
            
<a href="{node_url}">{node_title}</a>
        
{/exp:taxonomy:nav}
    
    
</fieldset>
{/exp:taxonomy:get_node} 

Want to say 'thank you'?

If you find any of my work useful, feel free to make a donation amount of your choosing via PayPal — or if you like, purchase a copy of Introvert from Devot-EE and you'll get something in return :)

↑ Back to top