ds_extras.pages.inc

  1. cis7 sites/all/modules/ulmus/ds/modules/ds_extras/includes/ds_extras.pages.inc
  2. cle7 sites/all/modules/ulmus/ds/modules/ds_extras/includes/ds_extras.pages.inc
  3. ecd7 sites/all/modules/ulmus/ds/modules/ds_extras/includes/ds_extras.pages.inc
  4. elmsmedia7 sites/all/modules/ulmus/ds/modules/ds_extras/includes/ds_extras.pages.inc
  5. harmony7 sites/all/modules/ulmus/ds/modules/ds_extras/includes/ds_extras.pages.inc
  6. icor7 sites/all/modules/ulmus/ds/modules/ds_extras/includes/ds_extras.pages.inc
  7. meedjum_blog7 sites/all/modules/ulmus/ds/modules/ds_extras/includes/ds_extras.pages.inc
  8. mooc7 sites/all/modules/ulmus/ds/modules/ds_extras/includes/ds_extras.pages.inc

Display Suite Extras page functions.

Functions

Namesort descending Description
ds_extras_node_page_view Menu callback: show an individual node with the Switch field.
ds_switch_view_mode_inline Menu callback: switches to another view mode inline.

File

sites/all/modules/ulmus/ds/modules/ds_extras/includes/ds_extras.pages.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Display Suite Extras page functions.
  5. */
  6. /**
  7. * Menu callback: show an individual node with the Switch field.
  8. */
  9. function ds_extras_node_page_view($node) {
  10. // If there is a menu link to this node, the link becomes the last part
  11. // of the active trail, and the link name becomes the page title.
  12. // Thus, we must explicitly set the page title to be the node title.
  13. drupal_set_title($node->title);
  14. $uri = entity_uri('node', $node);
  15. // Set the node path as the canonical URL to prevent duplicate content.
  16. drupal_add_html_head_link(array('rel' => 'canonical', 'href' => url($uri['path'], $uri['options'])), TRUE);
  17. // Set the non-aliased path as a default shortlink.
  18. drupal_add_html_head_link(array('rel' => 'shortlink', 'href' => url($uri['path'], array_merge($uri['options'], array('alias' => TRUE)))), TRUE);
  19. // Update the history table, stating that this user viewed this node.
  20. node_tag_new($node);
  21. // For markup consistency with other pages, use node_view_multiple() rather than node_view().
  22. $view_mode = (!empty($node->ds_switch)) ? $node->ds_switch : 'full';
  23. // It's also possible to use $_GET['v'] to switch view modes.
  24. if (isset($_GET['v']) && !empty($_GET['v'])) {
  25. $view_mode = $_GET['v'];
  26. }
  27. drupal_static('ds_extras_view_mode', $view_mode);
  28. return node_view_multiple(array($node->nid => $node), $view_mode);
  29. }
  30. /**
  31. * Menu callback: switches to another view mode inline.
  32. */
  33. function ds_switch_view_mode_inline() {
  34. $content = '';
  35. $status = TRUE;
  36. $error = FALSE;
  37. $id = $_REQUEST['id'];
  38. $view_mode = $_REQUEST['view_mode'];
  39. $entity_type = $_REQUEST['entity_type'];
  40. $entity = entity_load($entity_type, array($id));
  41. if (!isset($entity[$id])) {
  42. $status = FALSE;
  43. $error = t('Content was not found.');
  44. }
  45. else {
  46. if (node_access('view', $entity[$id])) {
  47. $element = node_view($entity[$id], $view_mode);
  48. $content = drupal_render($element);
  49. }
  50. else {
  51. $error = t('Access denied');
  52. }
  53. }
  54. drupal_add_http_header('Content-Type', 'text/javascript; charset=utf-8');
  55. print drupal_json_encode(array(
  56. 'status' => $status,
  57. 'content' => $content,
  58. 'errorMessage' => $error,
  59. ));
  60. exit();
  61. }