contextual-links-example-object.tpl.php

  1. examples
    1. 7 contextual_links_example/contextual-links-example-object.tpl.php
    2. 8 contextual_links_example/contextual-links-example-object.tpl.php

Default theme implementation to display a sample object with contextual links.

Available variables:

  • $title: The sanitized title of the object.
  • $content: The sanitized content of the object.

These are defined in template_preprocess_contextual_links_example_object() and represent whichever variables you might actually use to display the main content of your module's object.

Standard variables (required for contextual links):

  • $classes: String of classes that can be used to style contextually through CSS.
  • $title_prefix (array): An array containing additional output populated by modules, intended to be displayed in front of the main title tag that appears in the template.
  • $title_suffix (array): An array containing additional output populated by modules, intended to be displayed after the main title tag that appears in the template.

The above variables are a subset of those which Drupal provides to all templates, and they must be printed in your template file in order for contextual links to be properly attached. For example, the core Contextual Links module adds the renderable contextual links themselves inside $title_suffix, so they will appear immediately after the object's title in the HTML. (This placement is for accessibility reasons, among others.)

File

contextual_links_example/contextual-links-example-object.tpl.php
View source
  1. <?php
  2. /**
  3. * @file
  4. * Default theme implementation to display a sample object with contextual links.
  5. *
  6. * Available variables:
  7. * - $title: The sanitized title of the object.
  8. * - $content: The sanitized content of the object.
  9. * These are defined in template_preprocess_contextual_links_example_object()
  10. * and represent whichever variables you might actually use to display the
  11. * main content of your module's object.
  12. *
  13. * Standard variables (required for contextual links):
  14. * - $classes: String of classes that can be used to style contextually through
  15. * CSS.
  16. * - $title_prefix (array): An array containing additional output populated by
  17. * modules, intended to be displayed in front of the main title tag that
  18. * appears in the template.
  19. * - $title_suffix (array): An array containing additional output populated by
  20. * modules, intended to be displayed after the main title tag that appears in
  21. * the template.
  22. * The above variables are a subset of those which Drupal provides to all
  23. * templates, and they must be printed in your template file in order for
  24. * contextual links to be properly attached. For example, the core Contextual
  25. * Links module adds the renderable contextual links themselves inside
  26. * $title_suffix, so they will appear immediately after the object's title in
  27. * the HTML. (This placement is for accessibility reasons, among others.)
  28. */
  29. ?>
  30. <div class="<?php print $classes; ?>">
  31. <?php print render($title_prefix); ?>
  32. <h2><?php print $title; ?></h2>
  33. <?php print render($title_suffix); ?>
  34. <?php print $content; ?>
  35. </div>
Login or register to post comments