You are here

function _entity_print_views_get_css in Entity Print 7

Inject the relevant css for the template.

You can specify CSS files to be included for all views of per view in your themes css file. This code uses your current theme which is likely to be the front end theme.

Examples:

entity_print[views][all] = 'css/all-pdfs.css' entity_print[views][view_id] = 'css/this-view.css'

Parameters

object $view: The view we're rendering to a PDF.

Return value

array An array of stylesheets to be used for this template.

1 call to _entity_print_views_get_css()
views_plugin_display_entity_print_views_pdf::execute in modules/entity_print_views/includes/views/views_plugin_display_entity_print_views_pdf.inc
The display page handler returns a normal view, but it also does a drupal_set_title for the page, and does a views_set_page_view on the view.

File

modules/entity_print_views/entity_print_views.module, line 26
Entity Print Views module file.

Code

function _entity_print_views_get_css($view) {

  // Allow other modules to add their own CSS.
  module_invoke_all('entity_print_views_css', $view);
  global $theme;
  $theme_path = drupal_get_path('theme', $theme);
  $theme_info = drupal_parse_info_file($theme_path . "/{$theme}.info");

  // Parse out the CSS for all views.
  if (isset($theme_info['entity_print']['views']['all'])) {
    entity_print_add_css("{$theme_path}/" . $theme_info['entity_print']['views']['all']);
    unset($theme_info['entity_print']['views']['all']);
  }

  // Add any per view CSS files.
  foreach ($theme_info['entity_print']['views'] as $view_name => $css) {
    if ($view->name === $view_name) {
      entity_print_add_css("{$theme_path}/{$css}");
    }
  }

  // Grab all the css files and filter by group so we only have css defined to
  // be used in entity print.
  $entity_print_css = array_filter(drupal_add_css(), function ($a) {
    return $a['group'] === ENTITY_PRINT_CSS_GROUP;
  });
  return $entity_print_css;
}