1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- # @Author: Bachir Soussi Chiadmi <bach>
- # @Email: bachir@figureslibres.io
- # @Filename: edlp_ajax.module
- # @License: GPL-V3
- /**
- * Implements hook_theme().
- */
- function edlp_ajax_theme($existing, $type, $theme, $path) {
- // @see https://www.drupal.org/docs/8/theming/twig/create-custom-twig-templates-from-custom-module
- return array(
- 'edlp_ajax' => array(
- 'file' => 'includes/edlp_ajax.inc',
- 'variables' => array(
- 'entity_type' => 'node',
- 'entity' => NULL,
- 'view_mode' => 'default'
- ),
- ),
- );
- }
- /**
- * Implements hook_theme_suggestions_HOOK().
- */
- function edlp_ajax_theme_suggestions_edlp_ajax(array $vars) {
- // dpm($vars);
- $suggestions = [];
- // $node = $variables['elements']['#node'];
- $sanitized_view_mode = strtr($vars['view_mode'], '.', '_');
- //
- $suggestions[] = 'edlp_ajax__' . $vars['entity_type'];
- $suggestions[] = 'edlp_ajax__' . $vars['entity_type'] . '__' . $sanitized_view_mode;
- // $suggestions[] = 'node__' . $node->bundle() . '__' . $sanitized_view_mode;
- $suggestions[] = 'edlp_ajax__' . $vars['entity_type'] . '__' . $vars['entity']->id();
- $suggestions[] = 'edlp_ajax__' . $vars['entity_type'] . '__' . $vars['entity']->id() . '__' . $sanitized_view_mode;
- return $suggestions;
- }
|