You are here

function template_preprocess_recipe_total_time in Recipe 8.2

Prepares variables for the recipe_total_time template.

Default template: recipe_total_time.html.twig.

Parameters

array $variables: An associative array containing:

  • total_time: The content of the pseudo-field.
  • label: A string containing the pseudo-field's title.
  • label_display: The display settings for the label.

File

./recipe.module, line 212
Contains functions for Recipe node CRUD and display.

Code

function template_preprocess_recipe_total_time(&$variables, $hook) {

  // Add the RDF metadata to the content_attributes.
  $mapping = [
    'properties' => [
      'schema:totalTime',
    ],
    'datatype' => 'xsd:duration',
    'datatype_callback' => [
      'callable' => 'recipe_duration_iso8601',
    ],
  ];
  $variables['content_attributes'] = rdf_rdfa_attributes($mapping, $variables['total_time']['#duration']);
  $variables['label_hidden'] = $variables['label_display'] == 'hidden';
}