"page--alias--about-us" template file */ function betway_theme_suggestions_page_alter(array &$suggestions, array $variables) { // Response codes for Access Denied and Page Not Found. $session = \Drupal::request()->getSession(); $system_codes = [403, 404]; if ( Drupal::request()->attributes->get('exception') && $status_code = Drupal::request()->attributes->get('exception')->getStatusCode() ) { // Add Basic Page suggestion if one of above response codes. if (in_array($status_code, $system_codes)) { //$suggestions[] = 'page'; $suggestions[] = 'page__system__' . $status_code; } } // $hompage_node_id = $_SESSION['hompage_node_id']; // $node = \Drupal::entityTypeManager()->getStorage('node')->load($hompage_node_id); //$node = $_SESSION['homepage_node']; $node = $session->get('current_node'); if ($node) { $content_type = $node->bundle(); $suggestions[] = 'page__' . $content_type; $page_id = $node->id(); if (in_array($content_type, ['static', 'page','event'])) { $current_path = Drupal::service('path.current')->getPath(); $alias = Drupal::service('path.alias_manager')->getAliasByPath($current_path); // //alias for finance pages // $deposit_page_alias = pageAliasForFinancePages($_SERVER['REQUEST_URI']); // if ($deposit_page_alias) { // $suggestions[] = $deposit_page_alias; // } if ($alias != '') { // break up the alias "/about/us" => "", "about", "" ,"us" $parts = explode('/', $alias); // we only start suggestion with one "-" because first "/" will become extra "-" $suggestion = 'page__alias'; foreach ($parts as $part) { // subsequent suggestions get appended $suggestion .= '_' . "$part"; } // turn "-" in "_" $suggestion = str_replace('-', '_', $suggestion); $suggestions[] = $suggestion; if($content_type == "event"){ //Icon $url = file_create_url($node->field_icon->entity->uri->value); $urlTemp = explode(":",$url); $node->field_icon->entity->uri->value = $urlTemp[1]; //Background Image $url = file_create_url($node->field_banner_web->entity->uri->value); $urlTemp = explode(":",$url); $node->field_banner_web->entity->uri->value = $urlTemp[1]; //Field Event Style $style = $node->field_event_style->value; //Get All the style //Styling $themeName = \Drupal::config('system.theme')->get('default'); $themeNameDir = dirname(drupal_get_filename('theme', $themeName)); $styleFilePath = '/templates/event/style.json'; $stylePath = DRUPAL_ROOT . '/' . $themeNameDir . '/' . $styleFilePath ; $styleList = json_decode(file_get_contents($stylePath), true); $landingStyleList = []; foreach ($styleList['styles'] as $val) { $landingStyleList[$val['filename']] = $val['name']; } if (array_key_exists($style, $landingStyleList)) { $suggestion = str_replace('-', '_', $style); $suggestions[] = $suggestion; } } } // load the Landing Page Setting $PageRenderRepository = new PageRenderRepository; //$PageRenderList = $PageRenderRepository->all()->fetchAll(); $pageRendered = $PageRenderRepository->getByNid($page_id)->fetch(); if($pageRendered != false){ $suggestion = str_replace('-', '_', $pageRendered->style); $suggestions[] = $suggestion; } // $landingStyleList = get_styles(); // foreach ($PageRenderList as $name => $page) { // if ($page_id == $page->nid) { // $suggestion = str_replace('-', '_', $page->style); // $suggestions[] = $suggestion; // break; // } // } } } print_r($suggestions); } function betway_preprocess_page(&$variables) { $token = \Drupal::service('config.factory')->getEditable('example.settings')->get('message'); $lang = \Drupal::languageManager()->getCurrentLanguage()->getId(); $mobileType = ""; if (preg_match('/(iPhone|iPad|iPod)/', $_SERVER['HTTP_USER_AGENT'])) { $mobileType = "Apple"; } else { $mobileType = "Android"; } $variables['mobileType'] = $mobileType; $variables['lang'] = $lang; $variables['mobile_access_token'] = $token; $current_path = Drupal::service('path.current')->getPath(); $variables['page_class'] = str_replace("/","", Drupal::service('path.alias_manager')->getAliasByPath($current_path)); } //NEW DRUPAL RENDERING SYSTEM - START /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function betway_preprocess_html(&$variables) { $session = \Drupal::request()->getSession(); // Add node id to the body class. // $node = \Drupal::routeMatch()->getParameter('node'); $node = $session->get('homepage_node') ?? Drupal::routeMatch()->getParameter('node'); $session->set('current_node', $node); $session->set('page_type', "QRP"); $current_path = Drupal::service('path.current')->getPath(); $alias = Drupal::service('path.alias_manager')->getAliasByPath($current_path); $alias_str = str_replace('/', '', $alias); $parts = explode('/', $alias); if ($node) { $variables['attributes']['class'][] = 'node-' . $node->id(); if ($alias_str == 'home') { $variables['attributes']['class'][] = 'specificPage homePage'; } else { $variables['attributes']['class'][] = 'static-' . $alias_str; $variables['attributes']['class'][] = 'static-' . $parts[1]; } } // any faq page has different background color if ($parts[1] == 'faq') { $variables['attributes']['class'][] = getFaqBackgroundClass($parts[2]); } $apiSettings = new ApiSettingController; $variables['apiLists'] = $apiSettings->getAllApis(); //Delete the "|" symbol on title if($node){ $variables['head_title']['title'] = $node->getTitle(); $variables['page']['#attached']['html_head'][0][0]['#attributes']['content'] = $node->getTitle(); }else{ $titles = explode(" | ",$variables['head_title']['title']); $variables['head_title']['title'] = $titles[0]; $variables['page']['#attached']['html_head'][0][0]['#attributes']['content'] = $titles[0]; } //Check Domain $variables['affiliate_code'] = $session->get('affiliate') != null ?$session->get('affiliate') :""; $variables['ga'] = $session->get('ga') != null ?$session->get('ga') :""; $variables['piwik'] = $session->get('piwik') != null ?$session->get('piwik') :""; $variables['la51'] = $session->get('la51') != null ?$session->get('la51') :""; // $variables['affiliate_code'] = $GLOBALS['qrpCodes']["affiliate"] != null ?$GLOBALS['qrpCodes']["affiliate"] :""; // $variables['ga'] = $GLOBALS['qrpCodes']["ga"] != null ?$GLOBALS['qrpCodes']["ga"] :""; // $variables['piwik'] = $GLOBALS['qrpCodes']["piwik"] != null ?$GLOBALS['qrpCodes']["piwik"] :""; // $variables['la51'] = $GLOBALS['qrpCodes']["la51"] != null ?$GLOBALS['qrpCodes']["la51"] :""; } //STYLES - START------------------------------------------------------------------------------ function betway_preprocess_page__alias__landing_style9(&$variables) { $session = \Drupal::request()->getSession(); //INITIALIZATION $langId = $variables['language']->getId(); // $node = Drupal::routeMatch()->getParameter('node'); $node = $session->get('current_node'); $page_id = $node->id(); $PageRenderRepository = new PageRenderRepository; $querys = $PageRenderRepository->getByNid($page_id)->fetch(); foreach ($querys as $name => $value) { if ($name == "id") { $page_id = $value; break; } } // load the Landing Page Setting $landing_components = get_style("page__alias__landing_style9"); //GET THE COMPONENTS foreach ($landing_components["components"] as $name => $value) { $variables[$value['id']] = component_call($page_id, $langId, $value['id']); } //GET THE BANNERS foreach ($landing_components["banners"] as $name => $value) { $variables[$value['id']] = getBanners($page_id, $langId, $value['id']); } } function betway_preprocess_page__alias__landing_style10(&$variables) { $session = \Drupal::request()->getSession(); //INITIALIZATION $langId = $variables['language']->getId(); $node = $session->get('current_node'); $page_id = $node->id(); $PageRenderRepository = new PageRenderRepository; $querys = $PageRenderRepository->getByNid($page_id)->fetch(); foreach ($querys as $name => $value) { if ($name == "id") { $page_id = $value; break; } } // load the Landing Page Setting $landing_components = get_style("page__alias__landing_style10"); //GET THE COMPONENTS foreach ($landing_components["components"] as $name => $value) { $variables[$value['id']] = component_call($page_id, $langId, $value['id']); } //GET THE BANNERS foreach ($landing_components["banners"] as $name => $value) { $variables[$value['id']] = getBanners($page_id, $langId, $value['id']); } } function betway_preprocess_page__alias__psg_landing_page(&$variables) { $session = \Drupal::request()->getSession(); //INITIALIZATION $langId = $variables['language']->getId(); $node = $session->get('current_node'); $page_id = $node->id(); $PageRenderRepository = new PageRenderRepository; $querys = $PageRenderRepository->getByNid($page_id)->fetch(); foreach ($querys as $name => $value) { if ($name == "id") { $page_id = $value; break; } } // load the Landing Page Setting $landing_components = get_style("page__alias__psg_landing_page"); //GET THE COMPONENTS foreach ($landing_components["components"] as $name => $value) { $variables[$value['id']] = component_call($page_id, $langId, $value['id']); } //GET THE BANNERS foreach ($landing_components["banners"] as $name => $value) { $variables[$value['id']] = getBanners($page_id, $langId, $value['id']); } } function betway_preprocess_page__alias__landing_style12(&$variables) { $session = \Drupal::request()->getSession(); //INITIALIZATION $langId = $variables['language']->getId(); $node = $session->get('current_node'); $page_id = $node->id(); $PageRenderRepository = new PageRenderRepository; $querys = $PageRenderRepository->getByNid($page_id)->fetch(); foreach ($querys as $name => $value) { if ($name == "id") { $page_id = $value; break; } } // load the Landing Page Setting $landing_components = get_style("page__alias__landing_style12"); //GET THE COMPONENTS foreach ($landing_components["components"] as $name => $value) { $variables[$value['id']] = component_call($page_id, $langId, $value['id']); } //GET THE BANNERS foreach ($landing_components["banners"] as $name => $value) { $variables[$value['id']] = getBanners($page_id, $langId, $value['id']); } } function betway_preprocess_page__alias__landing_page_style1(&$variables) { $session = \Drupal::request()->getSession(); //INITIALIZATION $langId = $variables['language']->getId(); $node = $session->get('current_node'); $page_id = $node->id(); $PageRenderRepository = new PageRenderRepository; $querys = $PageRenderRepository->getByNid($page_id)->fetch(); foreach ($querys as $name => $value) { if ($name == "id") { $page_id = $value; break; } } // load the Landing Page Setting $landing_components = get_style("page__alias__landing_page_style1"); //GET THE BANNERS foreach ($landing_components["banners"] as $name => $value) { $variables[$value['id']] = getBanners($page_id, $langId, $value['id']); } } function betway_preprocess_page__alias__landing_style14(&$variables) { $session = \Drupal::request()->getSession(); //INITIALIZATION $langId = $variables['language']->getId(); $node = $session->get('homepage_node'); $page_id = $node->id(); $PageRenderRepository = new PageRenderRepository; $querys = $PageRenderRepository->getByNid($page_id)->fetch(); foreach ($querys as $name => $value) { if ($name == "id") { $page_id = $value; break; } } // load the Landing Page Setting $landing_components = get_style("page__alias__landing_style14"); //GET THE COMPONENTS foreach ($landing_components["components"] as $name => $value) { $variables[$value['id']] = component_call($page_id, $langId, $value['id']); } //GET THE BANNERS foreach ($landing_components["banners"] as $name => $value) { $variables[$value['id']] = getBanners($page_id, $langId, $value['id']); } } //STYLES - END-------------------------------------------------------------------------------- //FUNCTIONS - START------------------------------------------------------------------------------ function get_style($style) { // get theme style json data $themeName = \Drupal::config('system.theme')->get('default'); $themeNameDir = dirname(drupal_get_filename('theme', $themeName)); $themeInfoYmlPath = DRUPAL_ROOT . '/' . $themeNameDir . '/' . sprintf('%s.info.yml', $themeName); $themeInfoYml = yaml_parse_file($themeInfoYmlPath); $styleFilePath = $themeInfoYml['style-filepath'] ? $themeInfoYml['style-filepath'] : '/templates/static/style.json'; $stylePath = DRUPAL_ROOT . '/' . $themeNameDir . '/' . $styleFilePath; $styleList = json_decode(file_get_contents($stylePath), true); return $styleList["structures"][$style]; } function component_call($fid, $lang, $position) { $PageRegionRepository = new PageRegionRepository; $component = $PageRegionRepository->getByPageIDAndRegion($fid, $position)->fetch(); $nid = ""; foreach ($component as $name => $value) { if ($name == "nid") { $nid = $value; break; } } $node = \Drupal::entityTypeManager()->getStorage('node')->load($nid); if ($node != null) { $tempArr = array('title' => $node->get('title')->getValue()[0]["value"], 'body_web' => $node->get('field_body_web')->getValue()[0]["value"]); } else { return null; } return $tempArr; } function getSingleBanner($tid, $lang, $position) { $PageRegionRepository = new PageRegionRepository; $component = $PageRegionRepository->getByPageIDAndRegion($tid, $position)->fetch(); $nid = ""; foreach ($component as $name => $value) { if ($name == "nid") { $nid = $value; break; } } if ($node = \Drupal::entityTypeManager()->getStorage('node')->load($nid)) { $tempArr = []; $tempArr['title'] = $node->get('title')->getValue()[0]["value"]; $tempArr['body_web'] = $node->get('field_body_web')->getValue()[0]["value"]; $tempArr['action_label_link_url'] = $node->get('field_link_web')->getValue()[0]["uri"]; $tempArr['action_label_link_act'] = $node->get('field_link_act_web')->getValue()[0]["value"]; $tempArr['action_label_link_text'] = $node->get('field_link_web')->getValue()[0]["title"]; $url = file_create_url($node->field_image_web->entity->getFileUri()); $urlTemp = explode(":", $url); $url = $urlTemp[1]; $tempArr['image_web'] = $url; $url = file_create_url($node->field_image_app->entity->getFileUri()); $urlTemp = explode(":", $url); $url = $urlTemp[1]; $tempArr['image_app'] = $url; return $tempArr; } return false; } function getBanners($tid, $lang, $position) { $PageRegionRepository = new PageRegionRepository; $components = $PageRegionRepository->getByPageIDAndRegion($tid, $position)->fetchAll(); $nid = []; foreach ($components as $name => $value) { foreach ($value as $valName => $valComponents) { if ($valName == "nid") { $nid[] = $valComponents; } } } $resultArr = []; foreach ($nid as $name => $value) { if ($node = \Drupal::entityTypeManager()->getStorage('node')->load($value)) { $tempArr = []; $tempArr['title'] = $node->get('title')->getValue()[0]["value"]; $tempArr['body_web'] = $node->get('field_body_web')->getValue()[0]["value"]; $tempArr['action_label_link_url'] = $node->get('field_link_web')->getValue()[0]["uri"]; $tempArr['action_label_link_act'] = $node->get('field_link_act_web')->getValue()[0]["value"]; $tempArr['action_label_link_text'] = $node->get('field_link_web')->getValue()[0]["title"]; $url = file_create_url($node->field_image_web->entity->getFileUri()); $urlTemp = explode(":", $url); $url = $urlTemp[1]; $tempArr['image_web'] = $url; $url = file_create_url($node->field_image_app->entity->getFileUri()); $urlTemp = explode(":", $url); $url = $urlTemp[1]; $tempArr['image_app'] = $url; $resultArr[] = $tempArr; } } if ($nid != null) { return $resultArr; } return false; } function getVideo($tid, $lang, $position) { $PageRegionRepository = new PageRegionRepository; $component = $PageRegionRepository->getByPageIDAndRegion($tid, $position)->fetch(); $nid = ""; foreach ($component as $name => $value) { if ($name == "nid") { $nid = $value; break; } } if ($node = \Drupal::entityTypeManager()->getStorage('node')->load($nid)) { $tempArr = []; $tempArr['title'] = $node->get('title')->getValue()[0]["value"]; $url = file_create_url($node->field_video->entity->getFileUri()); $urlTemp = explode(":", $url); $url = $urlTemp[1]; $tempArr['video'] = $url; $url = file_create_url($node->field_image_app->entity->getFileUri()); $urlTemp = explode(":", $url); $url = $urlTemp[1]; $tempArr['image_app'] = $url; return $tempArr; } return false; } function getVideoBanner($tid, $lang, $position) { $PageRegionRepository = new PageRegionRepository; $component = $PageRegionRepository->getByPageIDAndRegion($tid, $position)->fetch(); $nid = ""; foreach ($component as $name => $value) { if ($name == "nid") { $nid = $value; break; } } if ($node = \Drupal::entityTypeManager()->getStorage('node')->load($nid)) { $tempArr = []; $tempArr['title'] = $node->get('title')->getValue()[0]["value"]; $url = file_create_url($node->field_video->entity->getFileUri()); $urlTemp = explode(":", $url); $url = $urlTemp[1]; $tempArr['video'] = $url; $url = file_create_url($node->field_video_app_->entity->getFileUri()); $urlTemp = explode(":", $url); $url = $urlTemp[1]; $tempArr['video_app'] = $url; return $tempArr; } return false; } //FUNCTIONS - END-------------------------------------------------------------------------------- //NEW DRUPAL RENDERING SYSTEM - END ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////