Top Banner
Views & Panels
32

Best practices in Drupal 7 (Views, Panels ...)

Aug 23, 2014

Download

Internet

Sergiu Savva

How to increase the performance on you site?
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Best practices in Drupal 7 (Views, Panels ...)

Views & Panels

Page 2: Best practices in Drupal 7 (Views, Panels ...)

Sergiu Savva

Drupal Developer for 3 Years

Drupal user https://drupal.org/user/1758280LinkedIn profile http://lnkd.in/i9J7aSFacebook page http://www.facebook.com/Gamer4ik

Page 3: Best practices in Drupal 7 (Views, Panels ...)

Broken windows theory

Page 4: Best practices in Drupal 7 (Views, Panels ...)
Page 5: Best practices in Drupal 7 (Views, Panels ...)
Page 6: Best practices in Drupal 7 (Views, Panels ...)

Views

Page 7: Best practices in Drupal 7 (Views, Panels ...)

Views Execute order

http://www.kdweb.co.uk/blog/drupal-module-views-hook-sequence

hook_views_pre_view (&$view)⇓

hook_views_pre_build (&$view)⇓

hook_views_query_alter (&$view, &$query)⇓

hook_views_pre_execute (&$view)⇓

hook_views_pre_render (&$view)⇓

hook_views_post_render (&$view)

Page 8: Best practices in Drupal 7 (Views, Panels ...)

Fields excludesViews

Page 9: Best practices in Drupal 7 (Views, Panels ...)

Fields excludesViews

Page 10: Best practices in Drupal 7 (Views, Panels ...)

Views Custom text

Page 11: Best practices in Drupal 7 (Views, Panels ...)
Page 12: Best practices in Drupal 7 (Views, Panels ...)
Page 13: Best practices in Drupal 7 (Views, Panels ...)

Views Alternatives

Panel fields

Display mode (node, comment, entity … )

VS

Page 14: Best practices in Drupal 7 (Views, Panels ...)

Views Display mode

Page 15: Best practices in Drupal 7 (Views, Panels ...)

Views Additional tools

Page 16: Best practices in Drupal 7 (Views, Panels ...)

Entity View ModeViews Additional tools

Page 17: Best practices in Drupal 7 (Views, Panels ...)

hook_field_extra_fields()Fields Additional tools

/** * Implements hook_field_extra_fields(). */function HOOK_field_extra_fields() {

$extrafield_name = 'my_field';

foreach (array('page', 'article') as $node_type) {

$extra['node'][$node_type]['display'][$extrafield_name] = array(

'label' => t('Some freaking title'),

'description' => t('A serious description.'),

'weight' => 50, // default weight, can be changed on display form by site-builder.

); } return $extra; }

http://www.vdmi.nl/blog/attach-extra-or-pseudo-fields-any-entity-drupal

Page 18: Best practices in Drupal 7 (Views, Panels ...)

hook_node_view()Views Additional tools

/** * Implements hook_node_view(). * Also HOOK_entity_view() can be used. */

function HOOK_node_view($node, $view_mode, $langcode) {

$extrafields = field_extra_fields_get_display('node', $node->type, $view_mode);

$extrafield_name = 'my_field'; if (isset($extrafields[$extrafield_name]) && isset($extrafields[$extrafield_name]['visible']) && $extrafields[$extrafield_name]['visible']) {

// Your logic here.$node->content[$extrafield_name] = array('#markup' => 'Build array with content');

}}

http://www.vdmi.nl/blog/attach-extra-or-pseudo-fields-any-entity-drupal

Page 19: Best practices in Drupal 7 (Views, Panels ...)

Views Additional toolsViews pane field

Page 20: Best practices in Drupal 7 (Views, Panels ...)

Views & Panels Custom layout

Panels 3: Creating a custom layout in your theme https://drupal.org/node/495654

; Panels layouts. You can place multiple layouts under the "layouts" folder.plugins[panels][layouts] = layouts

my_theme.info

$plugin = array( 'title' => t('One row two columns'), 'category' => t('onerowtwocols'), 'icon' => 'onerowtwocols.png', 'theme' => 'onerowtwocols', 'css' => 'onerowtwocols.css', 'regions' => array(

'top' => t('Top'),'right' => t('Right side'),'left' => t('Left side')

),);

my_plugin.inc

Page 21: Best practices in Drupal 7 (Views, Panels ...)

Views & Panels Overloaded Pages

(Views == listing) == TRUE

(Views != one node) == TRUE

Page 22: Best practices in Drupal 7 (Views, Panels ...)

Views & Panels Overloaded Pages

Page 23: Best practices in Drupal 7 (Views, Panels ...)

Views & Panels SQL in template files

Do not use SQL in template files

Page 24: Best practices in Drupal 7 (Views, Panels ...)
Page 25: Best practices in Drupal 7 (Views, Panels ...)

Views Fields handler

Page 26: Best practices in Drupal 7 (Views, Panels ...)

Panels

Page 27: Best practices in Drupal 7 (Views, Panels ...)

block VS ctools content type plugins

Page 28: Best practices in Drupal 7 (Views, Panels ...)

Views Panels, Why so slow?

Page 29: Best practices in Drupal 7 (Views, Panels ...)
Page 30: Best practices in Drupal 7 (Views, Panels ...)
Page 31: Best practices in Drupal 7 (Views, Panels ...)
Page 32: Best practices in Drupal 7 (Views, Panels ...)

Thank You !!