[support] Views: sort by arbitrary field value

Joel Willers joel.willers at sigler.com
Tue Mar 13 13:52:07 UTC 2012


You could do sorting in the .tpl.php, if need be. Also, you could call the view programmatically, creating an array of sort terms, then filter by the node type, stepping through a loop of each term. 

Views is quite robust in capabilities, but specific search order isn't as kind. I suppose you could try something a bit more funky, building a content type that just has a weight and another content type, then use relationships to display the view. Or maybe add a weight field to each existing content type, setting a default to each one, then sorting by weight, like 1 for news, 2 for blog, 3 for page. Taxonomy could also do some fun stuff with sorting.

Hope that gives you some ideas.

Joel 


-----Original Message-----
From: support-bounces at drupal.org [mailto:support-bounces at drupal.org] On Behalf Of DTH
Sent: Monday, March 12, 2012 3:43 PM
To: support at drupal.org
Subject: [support] Views: sort by arbitrary field value

Say I have a view that lists all the nodes on my site. Say I have three content types: page, news, blog.

If I sort by content type, I can only sort by ascending or descending
order: e.g. "blog, news, page" or "page, news, blog".

What do I need to do if I want the articles to be sorted in an order of my choosing, say "news, blog, page"?

(I guess I could create separate views for each content type and attach them, but what if I had thirty content types, say, and added more regularly)
--
[ Drupal support list | http://lists.drupal.org/ ]


More information about the support mailing list