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

1,555 views

Published on

How to increase the performance on you site?

Published in: Internet
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,555
On SlideShare
0
From Embeds
0
Number of Embeds
28
Actions
Shares
0
Downloads
35
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

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

  1. 1. Views & Panels
  2. 2. Sergiu Savva Drupal Developer for 3 Years Drupal user https://drupal.org/user/1758280 LinkedIn profile http://lnkd.in/i9J7aS Facebook page http://www.facebook.com/Gamer4ik
  3. 3. Broken windows theory
  4. 4. Views
  5. 5. 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)
  6. 6. Fields excludes Views
  7. 7. Fields excludes Views
  8. 8. Views Custom text
  9. 9. Views Alternatives Panel fields Display mode (node, comment, entity … ) VS
  10. 10. Views Display mode
  11. 11. Views Additional tools
  12. 12. Entity View Mode Views Additional tools
  13. 13. 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
  14. 14. 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
  15. 15. Views Additional tools Views pane field
  16. 16. 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
  17. 17. Views & Panels Overloaded Pages (Views == listing) == TRUE (Views != one node) == TRUE
  18. 18. Views & Panels Overloaded Pages
  19. 19. Views & Panels SQL in template files Do not use SQL in template files
  20. 20. Views Fields handler
  21. 21. Panels
  22. 22. block VS ctools content type plugins
  23. 23. Views Panels, Why so slow?
  24. 24. Thank You !!

×