D6: Ajaxify your website - all node and term views - completely
Alle Node- und Term-Ansichten mit Ajax-Funktionalität anzeigen
Geht's noch?
Mit Drupal 6 seitenweite Ajax-Funktionalität bei der Anzeige von Nodes und Terms realisieren?
Ja, es geht ganz einfach.
Term-Ansichten
Immer wenn eine URL nach dem Schema /taxonomy/term/x angezeigt wird.
Node-Ansichten
Immer wenn eine URL nach dem Schema /node/x angezeigt wird.
Realisierung
Die Realisierung ist eine Einfache und wendet eine der generellen Funktionalitaeten von Views 2 an.
- Für die Anzeige der Terms muss lediglich die bereits vorhandene Ansicht "taxonomy_term" aktiviert und für Ajax konfiguriert werden.
Diese Ansicht hört auf alle URLs nach dem Schema /taxonomy/term/%. Wobei % als Argument die jeweils aktuelle Term ID einer URL ist. - Für die Anzeige der Nodes wird analog der Ansicht für die Taxonomie eine Ansicht für die Nodes erstellt.
Diese Ansicht hört auf alle URLs nach dem Schema /node/%. Wobei % als Argument die jeweils aktuelle Node ID einer URL ist.
Das ist eigentlich schon Alles was man tun muss um eine seitenweite Ajax-Funktionalität bei der Anzeige von Nodes und Terms zu realisieren.
Anhang
Als "Anhang" habe ich für beide Ansichten den Code zum Importieren als Ansicht beigefügt.
Die Ansicht "taxonomy_term" ist um die RSS Feedfunktionalität erweitert. Nach dem Import sollte die bereits existierende Ansicht gelöscht werden.
Ansicht "Taxonomy_Term":
$view = new view;
$view->name = 'Taxonomy_Term';
$view->description = 'A view to emulate Drupal core\'s handling of taxonomy/term; it also emulates Views 1\'s handling by having two possible feeds.';
$view->tag = 'default';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = '0';
$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('sorts', array(
'sticky' => array(
'id' => 'sticky',
'table' => 'node',
'field' => 'sticky',
'order' => 'DESC',
'relationship' => 'none',
),
'created' => array(
'id' => 'created',
'table' => 'node',
'field' => 'created',
'order' => 'DESC',
'granularity' => 'second',
'relationship' => 'none',
),
));
$handler->override_option('arguments', array(
'term_node_tid_depth' => array(
'id' => 'term_node_tid_depth',
'table' => 'node',
'field' => 'term_node_tid_depth',
'default_action' => 'not found',
'style_plugin' => 'default_summary',
'style_options' => array(
'count' => TRUE,
'override' => FALSE,
'items_per_page' => 25,
),
'wildcard' => 'all',
'wildcard_substitution' => 'All',
'title' => '%1',
'default_argument_type' => 'fixed',
'default_argument' => '',
'validate_type' => 'taxonomy_term',
'validate_fail' => 'not found',
'depth' => '0',
'break_phrase' => 1,
'relationship' => 'none',
'default_argument_fixed' => '',
'default_argument_php' => '',
'validate_argument_node_type' => array(
'album' => 0,
'artist' => 0,
'book' => 0,
'page' => 0,
'story' => 0,
'track' => 0,
),
'validate_argument_vocabulary' => array(
'3' => 0,
'4' => 0,
'1' => 0,
'5' => 0,
'2' => 0,
),
'validate_argument_type' => 'tids',
'validate_argument_php' => '',
),
'term_node_tid_depth_modifier' => array(
'id' => 'term_node_tid_depth_modifier',
'table' => 'node',
'field' => 'term_node_tid_depth_modifier',
'default_action' => 'ignore',
'style_plugin' => 'default_summary',
'style_options' => array(
'count' => TRUE,
'override' => FALSE,
'items_per_page' => 25,
),
'wildcard' => 'all',
'wildcard_substitution' => 'All',
'title' => '',
'default_argument_type' => 'fixed',
'default_argument' => '',
'validate_type' => 'none',
'validate_fail' => 'not found',
),
));
$handler->override_option('filters', array(
'status_extra' => array(
'id' => 'status_extra',
'table' => 'node',
'field' => 'status_extra',
'operator' => '=',
'value' => '',
'group' => 0,
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'relationship' => 'none',
),
));
$handler->override_option('access', array(
'type' => 'none',
'role' => array(),
'perm' => '',
));
$handler->override_option('use_ajax', TRUE);
$handler->override_option('use_pager', '1');
$handler->override_option('row_plugin', 'node');
$handler->override_option('row_options', array(
'teaser' => TRUE,
'links' => TRUE,
));
$handler = $view->new_display('page', 'Page', 'page');
$handler->override_option('path', 'taxonomy/term/%');
$handler->override_option('menu', array(
'type' => 'none',
'title' => '',
'weight' => 0,
));
$handler->override_option('tab_options', array(
'type' => 'none',
'title' => '',
'weight' => 0,
));
$handler = $view->new_display('feed', 'Core feed', 'feed');
$handler->override_option('items_per_page', 15);
$handler->override_option('use_pager', '1');
$handler->override_option('row_plugin', 'node_rss');
$handler->override_option('row_options', array(
'item_length' => 'default',
));
$handler->override_option('path', 'taxonomy/term/%/%/feed');
$handler->override_option('menu', array(
'type' => 'none',
'title' => '',
'weight' => 0,
));
$handler->override_option('tab_options', array(
'type' => 'none',
'title' => '',
'weight' => 0,
));
$handler->override_option('displays', array(
'page' => 'page',
'default' => 0,
));
$handler = $view->new_display('feed', 'Views 1 feed', 'feed_1');
$handler->override_option('items_per_page', 15);
$handler->override_option('use_pager', '1');
$handler->override_option('row_plugin', 'node_rss');
$handler->override_option('row_options', array(
'item_length' => 'default',
));
$handler->override_option('path', 'taxonomy/term/%/feed');
$handler->override_option('menu', array(
'type' => 'none',
'title' => '',
'weight' => 0,
));
$handler->override_option('tab_options', array(
'type' => 'none',
'title' => '',
'weight' => 0,
));
Ansicht "Node":
$view = new view;
$view->name = 'Node';
$view->description = '';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = '0';
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Node', 'default');
$handler->override_option('arguments', array(
'nid' => array(
'default_action' => 'ignore',
'style_plugin' => 'default_summary',
'style_options' => array(),
'wildcard' => 'all',
'wildcard_substitution' => 'Alle',
'title' => '',
'default_argument_type' => 'fixed',
'default_argument' => '',
'validate_type' => 'none',
'validate_fail' => 'empty',
'break_phrase' => 0,
'not' => 0,
'id' => 'nid',
'table' => 'node',
'field' => 'nid',
'relationship' => 'none',
'default_argument_user' => 0,
'default_argument_fixed' => '',
'default_argument_php' => '',
'validate_argument_node_type' => array(
'ajaxstory' => 0,
'ccktax' => 0,
'imagestory' => 0,
'page' => 0,
'profile' => 0,
'story' => 0,
),
'validate_argument_node_access' => 0,
'validate_argument_nid_type' => 'nid',
'validate_argument_vocabulary' => array(
'1' => 0,
),
'validate_argument_type' => 'tid',
'validate_argument_php' => '',
),
));
$handler->override_option('filters', array(
'status_extra' => array(
'id' => 'status_extra',
'table' => 'node',
'field' => 'status_extra',
),
));
$handler->override_option('access', array(
'type' => 'none',
'role' => array(),
'perm' => '',
));
$handler->override_option('use_ajax', TRUE);
$handler->override_option('items_per_page', 1);
$handler->override_option('row_plugin', 'node');
$handler = $view->new_display('page', 'Seite', 'page_1');
$handler->override_option('path', 'node/%');
$handler->override_option('menu', array(
'type' => 'none',
'title' => '',
'weight' => 0,
));
$handler->override_option('tab_options', array(
'type' => 'none',
'title' => '',
'weight' => 0,
));
- Anmelden oder Registrieren um Kommentare zu schreiben
Neue Kommentare
vor 16 Stunden 11 Minuten
vor 18 Stunden 53 Minuten
vor 19 Stunden 11 Minuten
vor 19 Stunden 42 Minuten
vor 20 Stunden 26 Minuten
vor 1 Tag 12 Stunden
vor 2 Tagen 2 Stunden
vor 2 Tagen 9 Stunden
vor 2 Tagen 12 Stunden
vor 2 Tagen 13 Stunden