[development] Sort nodes based on their position on a menu (views_handler_sort_menu_hierarchy?)

Ken Rickard agentrickard at gmail.com
Tue Jan 4 16:39:43 UTC 2011


The issue is that you cannot actually run a database query to sort the
menu correctly, due to the nesting of children. But you can come
close. (You also can't run a clean JOIN from {node} to {menu_links}
without either a SQL calculation or a helper module.

You might also try http://drupal.org/project/menu_node_views, which is
the project that tries to consolidate work on Menu integration for
Views, though it could use some work.  If nothing else, you can likely
steal its sort handler.

On Tue, Jan 4, 2011 at 9:53 AM, Andrew Fowlston <Andrew at pedalo.co.uk> wrote:
> Hi all,
>
> I'd like to sort a view of nodes by the position of the nodes within the primary links menu. I found reference to a method that used computed field to calculate a weight. I'm not dead-set against using that, but thought this might be a good chance to write my first sort handler. I turned to the views docs and promptly found views_handler_sort_menu_hierarchy. I haven't delved much further except to triple-check that I don't see anything in the Views UI that seems to correspond to this sort handler. A quick grep of the class name indicates it's probably for books (which makes a lot of sense), though I can't think why it wouldn't also be open for other content types.
>
> So my questions are:
>
> 1. Any comments from folk about the best way to achieve ordering of nodes by their position in the menu?
> 2. Has anyone used views_handler_sort_menu_hierarchy? Can someone explain why it's not available by default (at least for a 'general' content type)?
>
> Thanks in advance,
>
> Andy
>
> . . . . . . .
> Andy Fowlston
> +44 (0)20 8747 5068
> andrew at pedalo.co.uk
> Skype: andy.pedalo
> www.pedalo.co.uk
>
> This email is intended only for the above named addressee/s. This email may be confidential or legally privileged. If you have received this email and you are not a named addressee, you must not use, copy, distribute or disclose the email or any part of its contents or take any action in reliance on it. If you have received this email in error, please email the sender by replying to this message and delete it from your system. All reasonable precautions have been taken to ensure no viruses are present in this email.
>
> pedalo limited cannot accept responsibility for loss or damage arising from the use of this email or attachments and recommends that you subject these to your virus checking procedures prior to use. Any views or opinions presented are solely those of the author and not necessarily those of Pedalo Limited
>
> Please consider the environment before printing this email
>



-- 
Ken Rickard
agentrickard at gmail.com
http://ken.therickards.com


More information about the development mailing list