Documentation Center

Expanding child branches

When a taxonomy is only partially displayed, for example to a certain depth, you may want to display some branches in the taxonomy tree not being displayed because of the depth filter. Use the SetExpandKeywords method to pass an array of Strings containing the TCM URIs of branches you want displayed, overriding the depth filter.

ASP.NET
To expand child branches in ASP.NET you must add the child branches to expand in the code-behind because it cannot be passed in the ASPX code. The following code is an example of a standard .aspx page:
<%@ Page Language="C#" AutoEventWireup="true" Debug="true" 
	CodeFile="TaxonomyTestBasicProperties.aspx.cs" 
	Inherits="TaxonomyTestBasicProperties" %>
<%@ Import Namespace="Tridion.ContentDelivery.Taxonomies"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
	<head runat="server">
		<title>Taxonomy Control</title>
	</head>
	<body>
		<form id="form1" runat="server">
			<tridion:TaxonomyControl ID="taxBasicProperties" TaxonomyURI="tcm:94-535-512" runat="server">
			</tridion:TaxonomyControl>
		</form>
	</body>
</html>

The following code behind example demonstrates how to expanding child branches:

protected void Page_Load(object sender, EventArgs e)
{
	taxBasicProperties.SetExpandKeywords(new string[] {"tcm:94-540-1024", "tcm:94-541-1024"});
}
Java
In the following example, String [] expandURIS = { "tcm:94-3131-1024" }; contains a String array of TCM URIs you want expanded:
<%@ page language="java" contentType="text/html"%>
<%@page import="com.tridion.taxonomies.*,
com.tridion.taxonomies.filters.*"%>

<%@ taglib uri="http://www.sdl.com/delivery/tags/cd/2.0" prefix="tridion" %>

<% 
	CompositeFilter myCompositeFilter = new CompositeFilter();//create a new composite filter to hold filters
	myCompositeFilter.depthFiltering(2, DepthFilter.FILTER_DOWN);//add depth filter to composite filter
	myCompositeFilter.abstractKeywordFiltering(false, true);//
	String [] expandURIS = { "tcm:94-3131-1024" };//Keyword to expand 
%>
<html>  
	<head><title>Taxonomy Control</title></head>
	<body>   
		<form>
			<tridion:TaxonomyControl taxonomyURI="tcm:94-535-512" expandKeywords="<%= expandURIS %>" taxonomyFilter="<%=myCompositeFilter%>"/>
		</form>
	</body>
</html>