Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Alphabetic grouping of child pages

Go to End

4 Posts   1757 Views


Community Member, 25 Posts

10 July 2009 at 2:06am

Edited: 10/07/2009 2:08am


I'm designing a website that will have some pages containing a greater amount of subpages (up to 150 subpages per page - no way to split that up). The idea is to group the list of subpages by their first character, just like the categories in Wikipedia are displayed.

I've created a new model that will hold that subpages, having control that will output a list of all occuring first characters. So

<% control get_alphabet %>
<a href="#$char">$char</a>
<% end_control %>

in it's template will give me a heading navigation bar. Now I want the titles of all subpages to show up below their first character. The output should be like

<a name="A"/>
<li><a href...>Alien</a></li>
<li><a href...>Argon</a></li>
<li><a href...>Automobile</a></li>

<a name="B"/>
<li><a href...>Butterfly</a></li>

But the following code won't work:

<% control get_alphabet %>
<a name="$char"/>
<% control get_children_for_char($char) %>
<li><a href...>$Title</a></li>
<% end_control %>
<% end_control %>

I get an error in this template. If I take out the second control statement or put in a constant parameter, it won't complain. I guess, I cannot pass a variable parameter to a control block, like "get_children_for_char($char)"? How would I manage that? Are there alternatives?

Thanks and greatings!


Community Member, 25 Posts

13 July 2009 at 7:50pm

Hi again!

I would appreciate any comments/ideas on this issue. This would be also interesting for other people, as it's not a uncommon feature/behavior.



Forum Moderator, 5523 Posts

13 July 2009 at 10:31pm

The template parser does not support passing vars - <% control get_children_for_char($char) %>.

You would have to do this in PHP and return your own dataobject set

function ArticlesOrders() {
$abc = array('A','B','C');  // get alphabet
$output = new DataObjectSet(); // output;
foreach($abc as $char) {
   $articles = // write a dataobjectget which gets it on the char
   $output->push(new ArrayData(array(
  'Char' => $char,
  'Articles' => $articles
return $output;

In your template

<% control ArticlesOrders %>
<% control Articles %>.....<% end_control %>
<% end_control %>


Community Member, 110 Posts

17 November 2010 at 1:35am


I know it's an old post, but i'm in need of exactly the same functionality.
I have gone through the recipe , but i'm not sure how to implement it exactly.

It doesn't give me any output on my page.

I could really use an extended example.

tx in advance