Sort Navigation


I do have a Neos Page with currently 4 languages (12 languages by end of april) and everything worked fine. Now we got a new requirement:

Some pages have now to be sorted alphabetically in a menu (Neos.Neos:Menu) according to their title (that of course depends on the selected language). Currently all pages are sorted by the german name at the time of import via a command controller.

As it seems that we cannot sort the document tree in different language dimensions in different order, we wanted to sort the menu via ViewHelper. For Typo3 we found (VHS) ( for sorting. Is a ViewHelper like this (compare to available for Neos, too?

Or is there a better way to get this done?

Best regards,

Okay, I’ve now created a small proof-of-concept with a ViewHelper:

class SortLoopViewHelper extends ForViewHelper
     * @return void
    public function initializeArguments()
        $this->registerArgument('sortByTitle', 'boolean', 'Set to true in order to sort by title', false);

     * @param array $arguments
     * @param \Closure $renderChildrenClosure
     * @param RenderingContextInterface $renderingContext
     * @return string
     * @throws ViewHelper\Exception
    public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
        if (array_key_exists("sortByTitle", $arguments) && is_bool($arguments['sortByTitle']) && $arguments['sortByTitle']) {
            usort($arguments['each'], function($array1, $array2) {
                $coll = Collator::create('de_DE');
                return $coll->compare($array1['node']->getProperty("title"), $array2['node']->getProperty("title"));

        return parent::renderStatic($arguments, $renderChildrenClosure, $renderingContext);

And I’m calling this in the template using:

<test:sortLoop each="{items}" as="item" iteration="menuItemIterator" sortByTitle="{sortByTitle}">

Works great and I’ll finalize it this way. Maybe it’s interesing for someone else…