Topic: Sort children?

Here's my children navigation:

<?php $artikelen = $this->children(array()); ?>
<ul>
<?php foreach ($artikelen as $artikel): ?>
<li<?php echo (url_start_with($artikel->url)) ? ' id="current_sub"': null; ?>><?php echo $artikel->link(); ?></li>
<?php endforeach; ?>
</ul>

But how can I make its order ascending/descending?

Re: Sort children?

<?php $artikelen = $this->children(array('order' => 'page.position ASC')); ?>

Should be enough I think.... in the same way you can add:

- offset
- limit
- where

Wolf CMS founder and lead developer
Please always check the Support forums and Wiki before asking. (My Ohloh account.)
Like Wolf CMS? Consider making a financial contribution.

Re: Sort children?

mvdkleijn wrote:
<?php $artikelen = $this->children(array('order' => 'page.position ASC')); ?>

Should be enough I think.... in the same way you can add:

- offset
- limit
- where

Thanks Martijn, I knew once but could not find any resource in a short time.
Its wonderfull to have this stuff in the toolbox.

Re: Sort children?

Well I tried this code straight in the default Articles sidebar tab of Wolf:

<?php $articles = $this->children(array('order' => 'page.position ASC')); ?>
<ul>
<?php foreach ($articles as $articel): ?>
<li<?php echo (url_start_with($articel->url)) ? ' id="current_sub"': null; ?>>
<?php echo $articel->link(); ?></li>
<?php endforeach; ?>
</ul>

I tried both DESC and ASC and I expected it to make a difference in order.
But it doesn't seem to work here.
Is there something i'm doing wrong?

Note: fresh install using Wolf_r151.zip

Last edited by Fortron (2010-03-21 23:15)

Re: Sort children?

Hmm... well, maybe position wasn't the best example smile

The position field defaults to 0 unless you've moved the page in the page hierarchy. So ordering by just position probably isn't enough.

Wolf's default behaviour in terms of ordering in the children() function is: page.position, page.id
(yes, without specifying ASC or DESC)

Wolf CMS founder and lead developer
Please always check the Support forums and Wiki before asking. (My Ohloh account.)
Like Wolf CMS? Consider making a financial contribution.

6

Re: Sort children?

And FWIW, there is a page on this in the Wiki, which includes a note on sort orders (for future reference!). wink