Alphabetical Listing Problem

Chad_Dupuis - October 26, 2007 - 18:28
Project:Views Bonus Pack
Version:5.x-1.x-dev
Component:Summary and Full View
Category:bug report
Priority:critical
Assigned:Unassigned
Status:closed
Description

I've seen others with the same issue, but none of the fixes have seemed to make a difference on my site. Anyhow, I have an alphabetical view on the page ( http://www.yinyanghouse.com/theory/herbalmedicine/tcm_herbal_medicine_da... ) sorted by the node title. I get multiple letters "X" for examples shows up twice with (1) node but they both contain both "X" nodes.

* B (1)
* D (1)
* M (1)
* S (1)
* X (1)
* X (1)
* Y (1)
* Z (1)

From the "X" page:
*
Xi Jiao (Rhinoceros Horn)
*
Xuan Shen (Ningpo Figwort Root)

I don't know if this is a problem with views, or just my code. I've included the view itself below and would greatly appreciate any help in making this work correctly.

Here is the view:

  $view = new stdClass();
  $view->name = 'tcm_herbal_medicine_database';
  $view->description = 'First letter of term on top and related view on bottom of each page.';
  $view->access = array (
);
  $view->view_args_php = '';
  $view->page = TRUE;
  $view->page_title = 'TCM Herbal Medicine Database';
  $view->page_header = '<p>Our Traditional Chinese Medicine herbal database contains usage information for the majority of the herbs used in clinical settings around the world.  You may view the individual herbs by clicking on the first letter of the <strong>Chinese Name</strong> or by searching through other groupings such as <a href="/theory/herbalmedicine/tcm_herbs_by_channel">by channel</a>, <a href="/theory/herbalmedicine/tcm_herbs_by_property">properties</a>, or <a href="/theory/herbalmedicine/tcm_herbs_by_function">functions &amp; actions</a>.</p>
<p>This section is very much <strong>a work in progress</strong>, so please check back if you are not finding the herbal information you are looking for.</p>';
  $view->page_header_format = '3';
  $view->page_footer = '<br><br><div class="item-list"><ul><li><strong>Discussions</strong>:</li><li><a href="/theory/herbal_medicine_theory_discussions">Discuss Herbal Medicine</a></li></ul></div><p><a name="sources"></a></p><h3>Sources and More Information</h3><p>The information on our site is drawn from our own lecture notes and clinical experience.</p><p>For a complete list of valuable resources, see our <a href="/research/herbal_medicine_resources">Herbal Medicine Resources</a> section.</p>';
  $view->page_footer_format = '3';
  $view->page_empty = '';
  $view->page_empty_format = '1';
  $view->page_type = 'list';
  $view->url = 'theory/herbalmedicine/tcm_herbal_medicine_database';
  $view->use_pager = TRUE;
  $view->nodes_per_page = '10000';
  $view->menu = TRUE;
  $view->menu_title = '';
  $view->menu_tab = FALSE;
  $view->menu_tab_weight = '0';
  $view->menu_tab_default = FALSE;
  $view->menu_tab_default_parent = NULL;
  $view->menu_tab_default_parent_type = 'normal';
  $view->menu_parent_tab_weight = '0';
  $view->menu_parent_title = '';
  $view->sort = array (
    array (
      'tablename' => 'node',
      'field' => 'title',
      'sortorder' => 'ASC',
      'options' => '',
    ),
  );
  $view->argument = array (
    array (
      'type' => 'nodeletter',
      'argdefault' => '6',
      'title' => '%1',
      'options' => '1',
      'wildcard' => '',
      'wildcard_substitution' => '',
    ),
    array (
      'type' => 'nodeletter',
      'argdefault' => '2',
      'title' => '%2',
      'options' => '',
      'wildcard' => '',
      'wildcard_substitution' => '',
    ),
  );
  $view->field = array (
    array (
      'tablename' => 'node',
      'field' => 'title',
      'label' => '',
      'handler' => 'views_handler_field_nodelink',
      'sortable' => '1',
      'options' => 'link',
    ),
  );
  $view->filter = array (
    array (
      'tablename' => 'node',
      'field' => 'status',
      'operator' => '=',
      'options' => '',
      'value' => '1',
    ),
    array (
      'tablename' => 'node',
      'field' => 'type',
      'operator' => 'OR',
      'options' => '',
      'value' => array (
  0 => 'tcmindividualherb',
),
    ),
  );
  $view->exposed_filter = array (
  );
  $view->requires = array(node);
  $views[$view->name] = $view;

#1

Chad_Dupuis - October 30, 2007 - 14:52
Priority:normal» critical

A response would be appreciated. I have the exact same setup with a previous version of views and views bonus pack on another site and the exact same view works fine.

This is a very commonly needed view and I would like to understand why this isn't working. Particularly if it is something in the view or something I'm doing....

#2

Chad_Dupuis - December 3, 2007 - 16:51
Version:5.x-1.2-alpha1» 5.x-1.x-dev

I've now tried the dev version as well and am still experiencing the same problem. If anyone could offer any advice to create this listing correctly, I would appreciate it greatly.

I've tried everything I can find and just cannot get the items count to be correct. If anyone has a view where they have alphabetical listings of node titles and it works correctly, please post it.

#3

budda - February 28, 2008 - 17:47

I've just installed the Views Bonus and cloned the "taxonomy_directory" supplied View (Summary + Full View). Made no changes other than the title and URL.

I have 1 node with two taxonomy terms associated to it. Instead of "J (2)" I get the alphabetical view of :

    * A (1) |
    * B (1) |
    * C (1) |
    * E (1) |
    * J (1) |
    * J (1) |
    * S (1) |
    * W (1) |

I don't know where to start in debugging this.

#4

budda - February 28, 2008 - 18:08
Component:Code» Summary and Full View

Updating component.

#5

budda - February 28, 2008 - 18:12
Category:support request» bug report

A little more research reveals that theme_views_bonus_summary_combo_top() function loops through an array of nodes.
The array provided to it looks something like this:

Array
(
    [0] => stdClass Object
        (
            [tid] => 9
            [letter] => A
            [num_nodes] => 1
            [term_data_weight] => 0
            [term_data_name] => Aicardi
            [node_sticky] => 0
            [node_created_created] => 1204218297
        )

    [1] => stdClass Object
        (
            [tid] => 12
            [letter] => B
            [num_nodes] => 1
            [term_data_weight] => 0
            [term_data_name] => Benefits
            [node_sticky] => 0
            [node_created_created] => 1204217091
        )

    [2] => stdClass Object
        (
            [tid] => 8
            [letter] => C
            [num_nodes] => 1
            [term_data_weight] => 0
            [term_data_name] => Childhood Epilepsies
            [node_sticky] => 0
            [node_created_created] => 1204218124
        )

    [3] => stdClass Object
        (
            [tid] => 13
            [letter] => E
            [num_nodes] => 1
            [term_data_weight] => 0
            [term_data_name] => Entitlements
            [node_sticky] => 0
            [node_created_created] => 1204217091
        )

    [4] => stdClass Object
        (
            [tid] => 11
            [letter] => J
            [num_nodes] => 1
            [term_data_weight] => 0
            [term_data_name] => Janz syndrome
            [node_sticky] => 0
            [node_created_created] => 1204218396
        )

    [5] => stdClass Object
        (
            [tid] => 10
            [letter] => J
            [num_nodes] => 1
            [term_data_weight] => 0
            [term_data_name] => Juvenile myoclonic epilepsy
            [node_sticky] => 0
            [node_created_created] => 1204218396
        )

    [6] => stdClass Object
        (
            [tid] => 7
            [letter] => S
            [num_nodes] => 1
            [term_data_weight] => 0
            [term_data_name] => Syndromes
            [node_sticky] => 0
            [node_created_created] => 1204218124
        )

    [7] => stdClass Object
        (
            [tid] => 14
            [letter] => W
            [num_nodes] => 1
            [term_data_weight] => 0
            [term_data_name] => Welfare
            [node_sticky] => 0
            [node_created_created] => 1204217091
        )

)

The node list needs to be grouped the item->letter -- but in the above array dump you can see two items with the letter = 'J'.

#6

budda - February 29, 2008 - 10:02
Status:active» patch (code needs review)

Fixed in the theme function. Stick this in your themes template.php:

function phptemplate_views_bonus_summary_combo_top($view, $nodes) {
  drupal_add_css(drupal_get_path('module', 'views_bonus_summary_combo') .'/views_bonus.css');

  foreach ($nodes as $node) {
    $group[$node->letter][] = $node;
  }

  foreach ($group as $node) {
    $items[] = views_get_summary_link($view->argument[0]['type'], $node[0], $view->url)  . "&nbsp;(" . count($node) . ")&nbsp;";
  }
  if ($items) {
    return '<div id="views_bonus_summary_top">'. implode(' | ', $items) .'</div>';
  }
}

Not the greatest code, but it works with the first loop correctly grouping the nodes by letter. I Also fixed the ugly divider pipes doubling up. Code can probably go back in to the main module if somebody cares to make a patch.

#7

dmitrig01 - May 10, 2008 - 14:24
Status:patch (code needs review)» fixed

Comitted

#8

Anonymous (not verified) - May 24, 2008 - 14:32
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.