# @Date: 13-12-2017 # @Email: bachir@figureslibres.io # @Filename: edlp_home.module # @Last modified by: bach # @Last modified time: 20-12-2017 # @License: GPL-V3 /** * Implements hook_theme(). */ function edlp_home_theme($existing, $type, $theme, $path) { // @see https://www.drupal.org/docs/8/theming/twig/create-custom-twig-templates-from-custom-module return array( 'edlp_home' => array( // 'render element' => '', 'file' => 'includes/edlp_home.inc', 'variables' => array( // 'presentation_node' => NULL, // 'last_fil_node' => NULL, // 'last_production_node' => NULL, 'promoted_statics' => array(), 'promoted_prods' => array(), 'lastdocs_items' => NULL, 'agenda_items' => NULL, // 'entrees_items' => NULL, 'collection_link' => NULL, 'production_link' => NULL, 'agenda_link' => NULL, ), ), ); } /** * Implements hook_theme_suggestions_HOOK(). */ function edlp_home_theme_suggestions_edlp_home_alter(array &$suggestions, array $variables) { $is_mobile_domain = false; // get domains from domain module $domain_storage = \Drupal::entityTypeManager()->getStorage('domain'); $mobile_domain_id = 'm_encyclopediedelaparole_org'; // $mobile_domain = $domain_storage->load('m_encyclopediedelaparole_org'); global $base_root; // get the current hostname (domain) $current_hostname = preg_replace('/http:\/\/|https:\/\//i', '', $base_root); // get the current domain $current_domain = $domain_storage->loadByHostname($current_hostname); if($current_domain){ // we are in a main domain // $is_mobile_domain = ($current_domain->id() == $mobile_domain_id); $current_domain_id = $current_domain->id(); }else{ // we are not in a main domain, so we look for an alias $domain_alias_storage = \Drupal::entityTypeManager()->getStorage('domain_alias'); $alias = $domain_alias_storage->loadByHostname($current_hostname); // dpm($alias, '$alias'); $current_domain_id = $alias->getDomainId(); } $is_mobile_domain = $current_domain_id == $mobile_domain_id; if($is_mobile_domain){ array_unshift($suggestions, 'edlp_home__mobile'); } }