소스 검색

Adding instructions for multilingual functionality (preprocess function for theme)

logicp 8 년 전
부모
커밋
7b7c69ef62
1개의 변경된 파일24개의 추가작업 그리고 1개의 파일을 삭제
  1. 24 1
      README.md

+ 24 - 1
README.md

@@ -1,3 +1,26 @@
 # cesium-drupal
 
-Integration of Cesium JS 3D mapping software with Drupal 8
+Integration of Cesium JS 3D mapping software with Drupal 8
+
+Be sure to stick this in your theme:
+
+function myTheme_preprocess_page(&$variables) {
+    $langCode = \Drupal::languageManager()->getCurrentLanguage()->getId();
+    if (\Drupal::service('path.current')->getPath() === '/map') {
+        if ($langCode === 'fr') {
+            $variables['#attached']['library'][] = 'qd30map/cesiumAdditionsFr';
+        } else {
+            $variables['#attached']['library'][] = 'qd30map/cesiumAdditions';
+        }
+    }
+
+    if (isset($variables['node'])) {
+        if ($variables['node']->getType() == 'boutique') {
+              $variables['#attached']['library'][] = 'qd30map/cesiumMini';
+                $node = \Drupal::routeMatch()->getParameter('node');
+                if ($node) {
+                  $variables['#attached']['drupalSettings']['boutique_title'] = $node->getTitle();
+                }
+        }
+    }
+}