Vista Dettaglio nodi + allegati senza duplicati

7 contenuti / 0 new
Ultimo contenuto
Vista Dettaglio nodi + allegati senza duplicati

Salve a tutti vorrei sapere se è possibile creare due viste su una stessa pagina che utilizzano gli stessi parametri in ingresso

- La prima vista mi mostra i dettagli dei nodi trovati con i parametri passati.
- La seconda vista mi mostra gli allegati di ogni nodo trovato.

La necessità nasce dal fatto che se utilizzo un unica vista, qundo in un nodo sono presenti 2 o + allegati la vista mi "duplica" anche i dettagli del nodo ;-(
(effettivamente in SQL sono due righe distinte.....)

L'alternativa è nel template della vista rifiltrarmi l'array $fields a mano togliendo i dettagli duplicati ma mi tocca a fargli fare almeno un paio di giri su un array che potrebbe contenere anche 100 elementi ;-(

Grazie Marco

Ciao,
in un progetto ho usato una vista con allegati del nodo (caricati con il modulo upload) ma non ho incontrato il problema di avere dei dati del nodo relativo duplicati (nel mio caso c'era solo il campo titolo).
Puoi postare un'esportazione della vista così da avere qualche info in più?

Maurizio Ganovelli - CHG Digital Solutions Web Agency

Ciao blackice78 nel mio caso forse è un pò + complesso, vado ad agire non sui nodi ma su un tipo di contenuto definito da me (evento_spc_dett) che tra l'altre cose è legato ad un altro tipo (evento_std) con flexiField ;-)
La vista la eseguo sul contenuto di tipo evento_spc_dett filtrando con due parametri (nid e id_regione) ti posto una expo:

$view = new view;
$view->name = 'dettEventoSpeciale';
$view->description = 'Visualizzazione del dettaglio regionale di un evento Speciale';
$view->tag = 'Visualizzazione del dettaglio regionale di un evento Speciale';
$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', 'dettEventoSpeciale', 'default');
$handler->override_option('fields', array(
  'field_nome_value' => array(
    'label' => 'Nome',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'link_to_node' => 0,
    'label_type' => 'widget',
    'format' => 'default',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 0,
    'id' => 'field_nome_value',
    'table' => 'node_data_field_nome',
    'field' => 'field_nome_value',
    'relationship' => 'none',
  ),
  'field_comuneevs_value' => array(
    'label' => 'Comune',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'link_to_node' => 0,
    'label_type' => 'widget',
    'format' => 'default',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 0,
    'id' => 'field_comuneevs_value',
    'table' => 'node_data_field_comuneevs',
    'field' => 'field_comuneevs_value',
    'relationship' => 'none',
  ),
  'field_dove_value' => array(
    'label' => 'Dove',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'link_to_node' => 0,
    'label_type' => 'widget',
    'format' => 'default',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 0,
    'id' => 'field_dove_value',
    'table' => 'node_data_field_dove',
    'field' => 'field_dove_value',
    'relationship' => 'none',
  ),
  'field_quando_value' => array(
    'label' => 'Quando',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'link_to_node' => 0,
    'label_type' => 'widget',
    'format' => 'default',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 0,
    'id' => 'field_quando_value',
    'table' => 'node_data_field_quando',
    'field' => 'field_quando_value',
    'relationship' => 'none',
  ),
  'field_evento_value' => array(
    'label' => 'Evento',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'link_to_node' => 0,
    'label_type' => 'widget',
    'format' => 'default',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 0,
    'id' => 'field_evento_value',
    'table' => 'node_data_field_evento',
    'field' => 'field_evento_value',
    'relationship' => 'none',
  ),
  'field_abbinamento_value' => array(
    'label' => 'Abbinamento',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'link_to_node' => 0,
    'label_type' => 'widget',
    'format' => 'default',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 0,
    'id' => 'field_abbinamento_value',
    'table' => 'node_data_field_abbinamento',
    'field' => 'field_abbinamento_value',
    'relationship' => 'none',
  ),
  'field_allegati_fid' => array(
    'label' => 'Allegati',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'link_to_node' => 0,
    'label_type' => 'widget',
    'format' => 'default',
    'multiple' => array(
      'group' => 0,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => 0,
    ),
    'exclude' => 0,
    'id' => 'field_allegati_fid',
    'table' => 'node_data_field_allegati',
    'field' => 'field_allegati_fid',
    'relationship' => 'none',
  ),
));
$handler->override_option('arguments', array(
  'nid' => array(
    'default_action' => 'empty',
    'style_plugin' => 'default_summary',
    'style_options' => array(),
    'wildcard' => 'all',
    'wildcard_substitution' => 'Tutti',
    'title' => '%1',
    'breadcrumb' => '%1',
    'default_argument_type' => 'fixed',
    'default_argument' => '',
    'validate_type' => 'none',
    'validate_fail' => 'not found',
    'break_phrase' => 0,
    'not' => 0,
    'id' => 'nid',
    'table' => 'node',
    'field' => 'nid',
    'validate_user_argument_type' => 'uid',
    'validate_user_roles' => array(
      '2' => 0,
      '3' => 0,
    ),
    'relationship' => 'none',
    'default_options_div_prefix' => '',
    'default_argument_user' => 0,
    'default_argument_fixed' => '',
    'default_argument_php' => '',
    'validate_argument_node_type' => array(
      'book' => 0,
      'evento_spc' => 0,
      'evento_spc_dett' => 0,
      'evento_std' => 0,
      'page' => 0,
      'simplenews' => 0,
      'socio' => 0,
      'story' => 0,
    ),
    'validate_argument_node_access' => 0,
    'validate_argument_nid_type' => 'nid',
    'validate_argument_vocabulary' => array(
      '6' => 0,
      '7' => 0,
      '1' => 0,
      '5' => 0,
      '2' => 0,
    ),
    'validate_argument_type' => 'tid',
    'validate_argument_transform' => 0,
    'validate_user_restrict_roles' => 0,
    'validate_argument_php' => '',
  ),
  'field_regione_value' => array(
    'default_action' => 'ignore',
    'style_plugin' => 'default_summary',
    'style_options' => array(),
    'wildcard' => 'all',
    'wildcard_substitution' => 'Tutti',
    'title' => '',
    'breadcrumb' => '',
    'default_argument_type' => 'fixed',
    'default_argument' => '',
    'validate_type' => 'none',
    'validate_fail' => 'not found',
    'break_phrase' => 0,
    'not' => 0,
    'id' => 'field_regione_value',
    'table' => 'node_data_field_regione',
    'field' => 'field_regione_value',
    'validate_user_argument_type' => 'uid',
    'validate_user_roles' => array(
      '2' => 0,
      '3' => 0,
    ),
    'relationship' => 'none',
    'default_options_div_prefix' => '',
    'default_argument_user' => 0,
    'default_argument_fixed' => '',
    'default_argument_php' => '',
    'validate_argument_node_type' => array(
      'book' => 0,
      'evento_spc' => 0,
      'evento_spc_dett' => 0,
      'evento_std' => 0,
      'page' => 0,
      'simplenews' => 0,
      'socio' => 0,
      'story' => 0,
    ),
    'validate_argument_node_access' => 0,
    'validate_argument_nid_type' => 'nid',
    'validate_argument_vocabulary' => array(
      '6' => 0,
      '7' => 0,
      '1' => 0,
      '5' => 0,
      '2' => 0,
    ),
    'validate_argument_type' => 'tid',
    'validate_argument_transform' => 0,
    'validate_user_restrict_roles' => 0,
    'validate_argument_php' => '',
  ),
));
$handler->override_option('filters', array(
  'type' => array(
    'operator' => 'in',
    'value' => array(
      'evento_spc' => 'evento_spc',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'type',
    'table' => 'node',
    'field' => 'type',
    'relationship' => 'none',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('cache', array(
  'type' => 'none',
));
$handler = $view->new_display('page', 'Pagina', 'page_1');
$handler->override_option('path', 'dettEventoSpeciale');
$handler->override_option('menu', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
  'name' => 'navigation',
));
$handler->override_option('tab_options', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
));

Ti posto anche l'SQL :
SELECT node.nid AS nid,
   node_data_field_regione.field_nome_value AS node_data_field_regione_field_nome_value,
   node.type AS node_type,
   node.vid AS node_vid,
   node_data_field_regione.field_comuneevs_value AS node_data_field_regione_field_comuneevs_value,
   node_data_field_regione.field_dove_value AS node_data_field_regione_field_dove_value,
   node_data_field_regione.field_quando_value AS node_data_field_regione_field_quando_value,
   node_data_field_regione.field_evento_value AS node_data_field_regione_field_evento_value,
   node_data_field_regione.field_evento_format AS node_data_field_regione_field_evento_format,
   node_data_field_regione.field_abbinamento_value AS node_data_field_regione_field_abbinamento_value,
   node_data_field_regione.field_abbinamento_format AS node_data_field_regione_field_abbinamento_format,
   node_data_field_allegati.field_allegati_fid AS node_data_field_allegati_field_allegati_fid,
   node_data_field_allegati.field_allegati_list AS node_data_field_allegati_field_allegati_list,
   node_data_field_allegati.field_allegati_data AS node_data_field_allegati_field_allegati_data,
   node_data_field_allegati.delta AS node_data_field_allegati_delta
FROM node node
INNER JOIN content_type_evento_spc_dett node_data_field_regione ON node.nid = node_data_field_regione.nid
LEFT JOIN content_field_allegati node_data_field_allegati ON node_data_field_regione.vid = node_data_field_allegati.vid
WHERE (node.type in ('evento_spc')) AND (node.nid = 360) AND (node_data_field_regione.field_regione_value = 20)

Grazie Marco

Sintetika s.r.l.
Communication Technology Innovation

www.sintetika.it

Vedi se risolvi così:
Vai in Modifica vista --> Campi --> Contenuto: Allegati --> Metti il flag su "Raggruppa i valori multipli", aggiorna il campo --> salva la vista.
Fammi sapere!

Maurizio Ganovelli - CHG Digital Solutions Web Agency

blackice78 wrote:
Vedi se risolvi così:
Vai in Modifica vista --> Campi --> Contenuto: Allegati --> Metti il flag su "Raggruppa i valori multipli", aggiorna il campo --> salva la vista.
Fammi sapere!

già provato ;-( ma se raggruppo i valori multipli drupal mi esclude dalla join le tabelle dei files
cioè l'SQL diventa :

SELECT node.nid AS nid,
   node_data_field_regione.field_nome_value AS node_data_field_regione_field_nome_value,
   node.type AS node_type,
   node.vid AS node_vid,
   node_data_field_regione.field_comuneevs_value AS node_data_field_regione_field_comuneevs_value,
   node_data_field_regione.field_dove_value AS node_data_field_regione_field_dove_value,
   node_data_field_regione.field_quando_value AS node_data_field_regione_field_quando_value,
   node_data_field_regione.field_evento_value AS node_data_field_regione_field_evento_value,
   node_data_field_regione.field_evento_format AS node_data_field_regione_field_evento_format,
   node_data_field_regione.field_abbinamento_value AS node_data_field_regione_field_abbinamento_value,
   node_data_field_regione.field_abbinamento_format AS node_data_field_regione_field_abbinamento_format,
FROM node node
INNER JOIN content_type_evento_spc_dett node_data_field_regione ON node.nid = node_data_field_regione.nid
WHERE (node.type in ('evento_spc')) AND (node.nid = 360) AND (node_data_field_regione.field_regione_value = 20)

;-( ..... mi sto orientando ad intercettare l'hook hook_views_pre_render e filtrarmi il $result a mano
una domanda hai utilizzato UploadModule e FileField ?
grazie
Marco

Sintetika s.r.l.
Communication Technology Innovation

www.sintetika.it

Sì utilizzo il modulo del core upload.module e il modulo filefield.
Perdonami, ma allora non ho capito qual'è l'obiettivo.
Questo è il risultato che ottengo e pensavo ti servisse qualcosa del genere:

Dalla query che costruisce la vista il left join scompare perchè poi in fase di fetching dei risultati per ogni nodo esegue una query a parte sulla tabella degli allegati e quelli che trova te li elenca sul campo allegati (o almeno così dovrebbe essere, ogni smentita è bene accetta!).
Quale risultato ottieni con gli stessi parametri (per l'esempio ho usato "all" per entrambi)?

Maurizio Ganovelli - CHG Digital Solutions Web Agency

Si Si SI vorrei ottenre propio questo ma a me propio non va non so...... ;-(
continuo ad avere un output di questo tipo (in dettaglio, non a griglia)

1° record
Nome
Campo Test
Comune
Campo Test
Dove
Campo Test
............
Allegati
LEttera1

2° record
Nome
Campo Test
Comune
Campo Test
Dove
Campo Test
............
Allegati
LEttera2

3°record
Nome
Campo Test 2
Comune
Campo Test 2
Dove
Campo Test 2
............
Allegati
lettera.txt

premetto che ho dovuto creare un campo mio di tipo fileField perchè con il modulo FlexiField il campo "allegati" presente di default non mi viene visualizzato...... mi sa che è il modulo flexiField che fà del casino .. mah..
Cmq ho risolto filtrando a mano il $result nel hook hook_views_pre_render, un pò "bruttino" ma AMEN.

Grazie Marco

Sintetika s.r.l.
Communication Technology Innovation

www.sintetika.it