a wee weblog, since 2006

Get Children Ids Tag

Fetches the entry_ids of a node's immediate children.

{exp:taxonomy:get_children_ids tree_id="1" entry_id="{entry_id}"}

Example output:

2|4|14|

Get Children Ids Tag Parameters

tree_id=

tree_id="1"

The id of the tree you want to fetch. This is a required parameter.

entry_id=

entry_id="{entry_id}"

The entry_id of the node being requested. This is a required parameter.

Example Usage

The example below shows how we use the tag to pass the entry_ids of the current page's children into an embed to display teaser information for those child pages.

{exp:channel:entries limit="1" disable="categories|member_data|pagination"}

  <h2>{title}</h2>

  {main_content}

  {embed='includes/.teasers' entry_ids='{exp:taxonomy:get_children_ids tree_id="1" entry_id="{entry_id}"}'}

{/exp:channel:entries}

In the embedded template 'includes/.teasers' we would call the exp:channel:entries tag with the fixed_order parameter: fixed_order="{embed:entry_ids}" to keep the order in check with Taxonomy. It also uses Taxonomy's {exp:taxonomy:node_url} Tag to fetch each entries url.

{if "{embed:entry_ids}" != ""}
	<h3>In this section</h3>
	<ul>
	{exp:channel:entries fixed_order="{embed:entry_ids}" dynamic="no"}
		<li><a href="{exp:taxonomy:node_url entry_id='{entry_id}' tree_id='1'}">{title}</a></li>
	{/exp:channel:entries}
	</ul>
{/if}

At the time of writing, EE displays an sql error if a null fixed_order parameter is passed. I suggest you check the children do exist in the parent template before embedding the sub template until the good folks at Ellislab release the fixed version.

As captured 26 April 2010 · The archived original