Argument pro Views block display
S využitím modulu Node Hierarchy se snažím zobrazit odkaz na rodičovský uzel pomocí Views. Používám k tomu pohledu (display) typu block (snažím se postupovat podle této diskuse. Pro omezení výpisu na rodiče zobrazeného uzlu se snažím použít následující argumenty:
Global: Null
Global: Null
Global: Null
Node: Nid – mám nastaveno, že v nepřítomnosti parametu bude použit parametr výchozí, určený PHP kódem: return $node->nid;
To by mělo odpovídat následujícímu URL, na které chci blok zobrazit:
http://example.cz/argument-1/argument-2/argument-3/id-uzlu
Při zobrazení uzlu, jenž má rodiče, však nedojde k vyfiltrování příslušného rodiče, jsou zobrazeny všechny uzly, mající potomka – jakoby parametr nebyl rozpoznán. Co dělám špatně? Vytvořil jsem testovací pohled typu stránka a tam vše funguje, jak má. Děkuji.
P.S. Připojuji ještě export použitého pohledu, pro lepší představu:
$view = new view;
$view->name = 'zobrazeni_titulu_v_knize';
$view->description = 'Zobrazení odpovídajícího titulu na stránce knihy';
$view->tag = '';
$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(
'parent' => array(
'label' => 'Parent Node',
'alter' => array(
'alter_text' => FALSE,
'text' => '',
'make_link' => FALSE,
'path' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'trim' => FALSE,
'max_length' => '',
'word_boundary' => TRUE,
'ellipsis' => TRUE,
'strip_tags' => FALSE,
'html' => FALSE,
),
'link_to_parent' => 1,
'display_as' => 'title',
'exclude' => '',
'id' => 'parent',
'table' => 'nodehierarchy',
'field' => 'parent',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
));
$handler->override_option('arguments', array(
'null' => array(
'default_action' => 'ignore',
'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',
'must_not_be' => 0,
'id' => 'null',
'table' => 'views',
'field' => 'null',
'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(
'patron' => 0,
'autor' => 0,
'clanek' => 0,
'kniha' => 0,
'knihovna' => 0,
'stranka' => 0,
'titul' => 0,
),
'validate_argument_node_access' => 0,
'validate_argument_nid_type' => 'nid',
'validate_argument_vocabulary' => array(
'6' => 0,
'4' => 0,
),
'validate_argument_type' => 'tid',
'validate_argument_transform' => 0,
'validate_user_restrict_roles' => 0,
'validate_argument_php' => '',
),
'null_1' => array(
'default_action' => 'ignore',
'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',
'must_not_be' => 0,
'id' => 'null_1',
'table' => 'views',
'field' => 'null',
'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(
'patron' => 0,
'autor' => 0,
'clanek' => 0,
'kniha' => 0,
'knihovna' => 0,
'stranka' => 0,
'titul' => 0,
),
'validate_argument_node_access' => 0,
'validate_argument_nid_type' => 'nid',
'validate_argument_vocabulary' => array(
'6' => 0,
'4' => 0,
),
'validate_argument_type' => 'tid',
'validate_argument_transform' => 0,
'validate_user_restrict_roles' => 0,
'validate_argument_php' => '',
),
'null_2' => array(
'default_action' => 'ignore',
'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',
'must_not_be' => 0,
'id' => 'null_2',
'table' => 'views',
'field' => 'null',
'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(
'patron' => 0,
'autor' => 0,
'clanek' => 0,
'kniha' => 0,
'knihovna' => 0,
'stranka' => 0,
'titul' => 0,
),
'validate_argument_node_access' => 0,
'validate_argument_nid_type' => 'nid',
'validate_argument_vocabulary' => array(
'6' => 0,
'4' => 0,
),
'validate_argument_type' => 'tid',
'validate_argument_transform' => 0,
'validate_user_restrict_roles' => 0,
'validate_argument_php' => '',
),
'nid' => array(
'default_action' => 'default',
'style_plugin' => 'default_summary',
'style_options' => array(),
'wildcard' => 'all',
'wildcard_substitution' => 'All',
'title' => '',
'default_argument_type' => 'php',
'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' => 'return $node->nid;',
'validate_argument_node_type' => array(
'patron' => 0,
'autor' => 0,
'clanek' => 0,
'kniha' => 0,
'knihovna' => 0,
'stranka' => 0,
'titul' => 0,
),
'validate_argument_node_access' => 0,
'validate_argument_nid_type' => 'nid',
'validate_argument_vocabulary' => array(
'6' => 0,
'4' => 0,
),
'validate_argument_type' => 'tid',
'validate_argument_transform' => 0,
'validate_user_restrict_roles' => 0,
'validate_argument_php' => '',
),
));
$handler->override_option('filters', array(
'parent' => array(
'operator' => '!=',
'value' => '',
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'parent',
'table' => 'nodehierarchy',
'field' => 'parent',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
));
$handler->override_option('access', array(
'type' => 'none',
));
$handler->override_option('items_per_page', 0);
$handler->override_option('style_plugin', 'list');
$handler->override_option('style_options', array(
'grouping' => '',
'type' => 'ul',
));
$handler = $view->new_display('block', 'Block', 'block_1');
$handler->override_option('block_description', '');
$handler->override_option('block_caching', -1);
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('path', 'pokusview/%/%/%/%');
$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,
));
Řešení?
Tak už jsem to (alespoň nějak) vyřešil za pomoci modulu ViewField, který je narozdíl od ViewReference schopen pamatovat si výchozí hodnoty jak použitého pohledu, tak příslušných parametrů. Problém byl také s argumenty Global:Null, nakonec jsem byl nucen použít URL http://example.cz/nid
Poslat nový komentář