You are here

function hook_paragraphs_previewer_page_alter in Paragraphs Previewer 7

Alter the paragraphs previewer page.

This is provides a hook to alter the page with context of the paragraph item, the parent node and form.

Example use case: Add custom CSS and JS to the preview page based on field values of the node.

Parameters

array $render: The render array for the paragraph.

array $context: An array with the following:

  • 'paragraph_item' object: The paragraph item object.
  • 'element' array: The element for the paragraph item. Only present on form previews.
  • 'node' object: The parent node object.
  • 'form' array: The parent form. Only present on form previews.
  • 'form_state' array: The parent form state. Only present on form previews.
1 invocation of hook_paragraphs_previewer_page_alter()
paragraphs_previewer_form_preview in ./paragraphs_previewer.pages.inc
Render a preview of the paragraph on an entity edit form.

File

./paragraphs_previewer.api.php, line 27
Hooks provided by the paragraphs_previewer module.

Code

function hook_paragraphs_previewer_page_alter(&$render, $context) {
  if (isset($context['node']) && !empty($context['node']->field_my_custom[LANGUAGE_NONE][0]['value'])) {
    $render['#attached']['css'][] = drupal_get_path('module', 'my_custom') . '/my_custom.css';
  }
}