function flip_preprocess_page in 3D Flipbook 8
Implements hook_preprocess_page().
1 string reference to 'flip_preprocess_page'
- flipbook_theme_registry_alter in ./
flipbook.module - Implements hook_theme_registry_alter().
File
- ./
flipbook.module, line 13 - Contains flipbook.module.
Code
function flip_preprocess_page(&$variables) {
$config = \Drupal::config('config.flipbook_chooseconfig');
$choice_value = $config
->get('pdf.choice');
global $base_url;
$host = $base_url;
$object = $variables['element']['#object'];
$typeLabel = $object
->get('name')
->getValue();
$flipbook = $object
->get('flipbook')
->getValue();
$flipdata = $flipbook[0]['target_id'];
$file1 = File::load($flipdata);
$url = file_create_url($file1
->getFileUri());
$variables['#attached']['drupalSettings']['pdfpath'][$flipdata] = $url;
$flipimage = $object
->get('flipbook_cover')
->getValue()[0]['target_id'];
$file = File::load($flipimage);
$coverimageurl = file_create_url($file
->getFileUri());
if ($choice_value == 1) {
$variables['#attached']['library'][] = 'flipbook/flipbook';
}
else {
$variables['#attached']['library'][] = 'flipbook/flipbook_nopopup';
}
$variables['#attached']['drupalSettings']['modulepath'] = drupal_get_path('module', 'flipbook');
$variables['#attached']['drupalSettings']['pdfpath'] = $url;
$variables['#attached']['drupalSettings']['pdfchoice'] = $choice_value;
$variables['#attached']['drupalSettings']['host'] = $host;
$variables['title'] = $typeLabel[0]['value'];
$variables['bannercover'] = $coverimageurl;
$variables['url'] = $url;
$variables['pdfchoice'] = $choice_value;
}