i searched a lot on this site, i found different articles about grouping in views, but it was either for old versions or non applicable. i ask sorry if i make anyone repeat.

I have multiple article entries, and some of them have exact same title (but different body).
I would like to have a VIEW similar with glossary, but where the Nodes are grouped by Title, instead of being listed individually.
Where should i be looking at?
i looked into "Using Views templates" but i am too new here to understand exactly what i should be doing.
thanks for helping!

Comments

jacopo3001’s picture

i think i found it, but still cannot make it work:

i went on: selected Views: basic settings : style : settings : group by...
selected TITLE, but the 2 nodes with same title are still listed separately
am i missing something?

merlinofchaos’s picture

Status: Active » Fixed

In the settings for either the style (the gear to the right of the 'Style' setting in the UI), there should be a 'grouping field'. Select your title there and it should automatically group by that field.

jacopo3001’s picture

Status: Fixed » Postponed (maintainer needs more info)

thank you for taking time to reply, and i am sorry to reopen this, but the method described on comment #2 is exactly the same one i use in #1, which is not working, or better, is not obtaining the desired result:

please check
http://lsp.alacity.com/?q=glossary/c

as you see now the VIEWS created 3 groups, one for each word.
But what i wanted was to have the 2 'ciao' grouped together.

to speak in basic sql language, i am looking for the same output i would get with:
SELECT count(*) as total, title FROM `node` group by title

How can i do that?
thanks again

merlinofchaos’s picture

Status: Postponed (maintainer needs more info) » Fixed

That's because you've got the title as a link to the node. That HTML is part of the string which is what's being considered for equality. They are not technically the same string, therefore don't group. Don't set the title to link. Instead, add a second title field; one that links, one that doesn't link. Use the not linking field for grouping and the linking field for display within the group. Set the not linking field to exclude.

This is a perfect example of how you can't have too much information in a request, since there was no way for me to know what you were doing until I actually saw it.

jacopo3001’s picture

Status: Fixed » Postponed (maintainer needs more info)

thanks, it works.
but still is not what i was looking for.

what i would like is to have the same output i would get with:
SELECT count(*) as total, title FROM `node` group by title

in a list would appear like:

  • ciao (2)
  • cabron (1)

when i click CIAO i would go to a page where all CIAO's entries are listed.

is this something we can using VIEWS controls? or if not, where should i modify?
thanks again

merlinofchaos’s picture

Ahh. What you want is a special kind of view called a summary view.

Add the Node: Title argument to your view.
Set the default action to 'summary, sorted ascending'.

Upon clicking update, you'll get the settings for the summary style; set it to the normal style, and then in the options tell it to include the record count. That should get you what you want, there.

Sorry about that, totally misunderstood what it is you were really trying to accomplish. My fault, since you did say in there.

jacopo3001’s picture

:( still not...

i added Arguments> node:tile
selected Summary, sorted ascending.
update
List style: List or Unformatted (i tried both, as i dont have NORMAL as you said)
then: Display record count with link

still wrong.
maybe i am missing something again? :S
you wanna try?: jalabiso/test123

if we make it, i promise i will write a full tutorial about it, but you need to accept my english :)

jacopo3001’s picture

i tried something, it fixed something but created problem elsewhere, i am lost:
http://lsp.alacity.com/?q=glossary
this is how it should look

but if i click on one letter (eg: C), i should 'filter' the same view for C only.
while it doesnt happen!

to obtain this i did:
arguments> node : title
title : %1
Summary, sorted ascending
Glossary mode: false

i am not sure if i am getting closer or not.

merlinofchaos’s picture

Sorry, you ended up on the wrong style. When you set an argument to have a 'summary' there should be a summary style that appears right beneath the argument in the list.

jacopo3001’s picture

i think understanding where the problem is (style of list is not a problem at this stage):

SUMMARY View is what i need, the problem is that SUMMARY VIEW only happens where there is not arguments.
so, http://lsp.alacity.com/?q=glossary/ is perfect, just the way i want it.

but when i click C, i would like to see the exact same type of list, just filtered by C.
but this apparently cannot happen, because when i click C i actually passing an argument, so SUMMARY VIEW will not be called (as it only works in case of missing arguments).
am i supposed to face this problem with another approach?

merlinofchaos’s picture

Status: Postponed (maintainer needs more info) » Fixed

The problem there is that you modified the existing argument rather than adding a new one, I think, because multiple arguments will stack and this view should have done that.

Here's a modification to the original glossary view that comes with Views that does what you want:

$view = new view;
$view->name = 'glossary';
$view->description = 'A list of all content, by letter.';
$view->tag = 'default';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('fields', array(
  'title' => array(
    'label' => 'Title',
    'link_to_node' => 1,
    'exclude' => 0,
    'id' => 'title',
    'table' => 'node',
    'field' => 'title',
    'relationship' => 'none',
  ),
  'name' => array(
    'label' => 'Author',
    'link_to_user' => 1,
    'exclude' => 0,
    'id' => 'name',
    'table' => 'users',
    'field' => 'name',
    'relationship' => 'none',
  ),
  'changed' => array(
    'label' => 'Last update',
    'date_format' => 'large',
    'custom_date_format' => '',
    'exclude' => 0,
    'id' => 'changed',
    'table' => 'node',
    'field' => 'changed',
    'relationship' => 'none',
  ),
));
$handler->override_option('arguments', array(
  'title' => array(
    'default_action' => 'default',
    'style_plugin' => 'default_summary',
    'style_options' => array(),
    'wildcard' => 'all',
    'wildcard_substitution' => 'All',
    'title' => '',
    'default_argument_type' => 'fixed',
    'default_argument' => '',
    'validate_type' => 'none',
    'validate_fail' => 'not found',
    'glossary' => 1,
    'limit' => '1',
    'case' => 'upper',
    'path_case' => 'lower',
    'transform_dash' => 0,
    'id' => 'title',
    'table' => 'node',
    'field' => 'title',
    'relationship' => 'none',
    'default_argument_user' => 0,
    'default_argument_fixed' => 'a',
    'default_argument_php' => '',
    'validate_argument_vocabulary' => array(),
    'validate_argument_type' => 'tid',
    'validate_argument_php' => '',
  ),
  'title_1' => array(
    'default_action' => 'summary asc',
    'style_plugin' => 'default_summary',
    'style_options' => array(
      'count' => 1,
      'override' => 0,
      'items_per_page' => '25',
    ),
    'wildcard' => 'all',
    'wildcard_substitution' => 'All',
    'title' => '%2',
    'default_argument_type' => 'fixed',
    'default_argument' => '',
    'validate_type' => 'none',
    'validate_fail' => 'not found',
    'glossary' => 0,
    'limit' => '0',
    'case' => 'none',
    'path_case' => 'none',
    'transform_dash' => 0,
    'id' => 'title_1',
    'table' => 'node',
    'field' => 'title',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
    'default_options_div_prefix' => '',
    'default_argument_user' => 0,
    'default_argument_fixed' => '',
    'default_argument_php' => '',
    'validate_argument_node_type' => array(
      'album' => 0,
      'artist' => 0,
      'book' => 0,
      'page' => 0,
      'story' => 0,
      'thing' => 0,
      'track' => 0,
    ),
    'validate_argument_node_access' => 0,
    'validate_argument_nid_type' => 'nid',
    'validate_argument_vocabulary' => array(
      '6' => 0,
      '3' => 0,
      '4' => 0,
      '1' => 0,
      '5' => 0,
      '2' => 0,
    ),
    'validate_argument_type' => 'tid',
    'validate_argument_php' => '',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
  'role' => array(),
  'perm' => '',
));
$handler->override_option('use_ajax', TRUE);
$handler->override_option('items_per_page', 36);
$handler->override_option('use_pager', '1');
$handler->override_option('style_plugin', 'table');
$handler->override_option('style_options', array(
  'grouping' => '',
  'override' => 1,
  'sticky' => 0,
  'order' => 'asc',
  'columns' => array(
    'title' => 'title',
    'name' => 'name',
    'changed' => 'changed',
  ),
  'info' => array(
    'title' => array(
      'sortable' => 1,
      'separator' => '',
    ),
    'name' => array(
      'sortable' => 1,
      'separator' => '',
    ),
    'changed' => array(
      'sortable' => 1,
      'separator' => '',
    ),
  ),
  'default' => 'title',
));
$handler = $view->new_display('page', 'Page', 'page');
$handler->override_option('path', 'glossary');
$handler->override_option('menu', array(
  'type' => 'normal',
  'title' => 'Glossary',
  'weight' => '0',
));
$handler->override_option('tab_options', array(
  'type' => 'none',
  'title' => '',
  'weight' => 0,
));
$handler = $view->new_display('attachment', 'Attachment', 'attachment');
$handler->override_option('arguments', array(
  'title' => array(
    'default_action' => 'summary asc',
    'style_plugin' => 'unformatted_summary',
    'style_options' => array(
      'count' => 1,
      'override' => 0,
      'items_per_page' => '25',
      'inline' => 1,
      'separator' => ' | ',
    ),
    'wildcard' => 'all',
    'wildcard_substitution' => 'All',
    'title' => '',
    'default_argument_type' => 'fixed',
    'default_argument' => '',
    'validate_type' => 'none',
    'validate_fail' => 'not found',
    'glossary' => 1,
    'limit' => '1',
    'case' => 'upper',
    'path_case' => 'lower',
    'transform_dash' => 0,
    'id' => 'title',
    'table' => 'node',
    'field' => 'title',
    'relationship' => 'none',
    'default_argument_user' => 0,
    'default_argument_fixed' => 'a',
    'validate_argument_vocabulary' => array(),
    'validate_argument_php' => '',
  ),
));
$handler->override_option('inherit_arguments', 0);
$handler->override_option('displays', array(
  'default' => 'default',
  'page' => 'page',
  'block_1' => 'block_1',
));
$handler = $view->new_display('block', 'Block', 'block_1');

BTW, adding the glossary complication to the top threw me for a loop at first. One thing at a time.

jacopo3001’s picture

Status: Fixed » Postponed (maintainer needs more info)

Please dont hate me... where should i change this?
should i do it directly on mysql, as i dont find any place to edit this in the interface...

jacopo3001’s picture

Status: Postponed (maintainer needs more info) » Fixed

great! i made it work.
( i couldnt copy your code but it gave me inspiration)

in Arguments, i will add node:title twice. the first one will handle the view for /?q=glossary , with no args.
the second will handle /?q=glossary/c

i am still not sure why is that, but it works.
as soon as i figure out it's meaning i will write a small tutorial, as promised.
thank you soooo much for all your time, hope i can pay back sometime

merlinofchaos’s picture

Oh, I'm sorry, this is another case of me being used to people undesrtanding imports.

That cdoe was an exported view; you cut and paste it into the 'import' textbox and it will create teh view on your system. That's how you share views across systems.

Arguments work like this:

First argument:
Is argument present? If no, 'do default action'. In this case, make a summary view.
If yes, 'filter view' -- now only nodes with a 'c' are present.

Second argument:
Is argument present? If no, 'do default action'. This is another summary view.
If yes, filter view -- now only nodes with a 'c' and that match the title are present.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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