开发者

Order nodes by Node reference field Using Views 2 (Drupal 6)

Drupal 6.20, Views 6.x-2.12.

I have a view listing nodes of type A, each one having a Node reference field mynoderef_field. I can show 开发者_StackOverflow中文版A.title and A.mynoderef_field, but they show up randomly. I want to order the nodes by A.mynoderef_field, but it does not appear as a possible "Order by" field.

I googled for a while, and couldn't find the answer. Any idea?

Thanks


this should do the trick:

<?php
function modulename_views_pre_render(&$view) {
  if ($view->name == 'field_name') {
    $new_result = array();
    $nids = explode(',', $view->args[0]);
    foreach ($nids as $nid) {
      foreach ($view->result as $res) {
        if ($res->nid == $nid) {
          $new_result[] = $res;
          break;
        }
      }
    }
    $view->result = $new_result;
  }
}
?>


I got this to work by using a relationship between the node A and mynoderef_field. Add node title to sort criteria and make sure the relationship is selected.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜