Browse Source

added exode urbain link

bach 1 year ago
parent
commit
87e03fcaf2

+ 10 - 0
config/sync/page_manager.page_variant.node-panels_variant-0.yml

@@ -175,6 +175,16 @@ variant_settings:
       region: first
       weight: -1
       uuid: b84fe2f8-7c0b-4976-aa63-d8dc5ae66fc0
+    532e0e26-eab4-476f-a964-fd68221d5619:
+      id: prog_exode_urbain_link
+      label: 'Prog exode urbain link'
+      label_display: '0'
+      provider: popsu_link_block
+      context_mapping: {  }
+      region: first
+      weight: -6
+      uuid: 532e0e26-eab4-476f-a964-fd68221d5619
+      link_title: 'Exode Urbain'
   page_title: ''
   layout: layout_threecol_25_50_25
   layout_settings:

+ 89 - 0
web/modules/custom/popsu_link_block/src/Plugin/Block/ProgExodeurbainLink.php

@@ -0,0 +1,89 @@
+<?php
+
+namespace Drupal\popsu_link_block\Plugin\Block;
+
+use Drupal\Core\Block\BlockBase;
+use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\Url;
+use Drupal\Core\Link;
+// use Drupal\Core\Utility\Token;
+
+/**
+ * Provides a 'ProgExodeurbainLink' block.
+ *
+ * @Block(
+ *  id = "prog_exode_urbain_link",
+ *  admin_label = @Translation("Prog exode urbain link"),
+ * )
+ */
+class ProgExodeurbainLink extends BlockBase {
+
+  public function blockForm($form, FormStateInterface $form_state) {
+    $form = parent::blockForm($form, $form_state);
+
+    $config = $this->getConfiguration();
+
+    $form['link_title_wrapper'] = [
+      '#type' => 'container'
+    ];
+
+    $form['link_title_wrapper']['link_title'] = [
+      '#type' => 'textfield',
+      '#title' => 'Link title',
+      '#default_value' => isset($config['link_title']) ? $config['link_title'] : "Ressources",
+      '#element_validate' => array('token_element_validate'),
+      '#token_types' => array('node'),
+    ];
+
+    $form['link_title_wrapper']['token_tree'] = array(
+      '#theme' => 'token_tree_link',
+      '#token_types' => array('node'),
+      '#show_restricted' => TRUE,
+      '#global_types' => FALSE,
+      '#weight' => 90,
+     );
+
+    return $form;
+  }
+
+  public function blockSubmit($form, FormStateInterface $form_state)
+  {
+    parent::blockSubmit($form, $form_state);
+    $values = $form_state->getValues();
+    $link_title = $values['link_title_wrapper']['link_title'];
+    $this->configuration['link_title'] = $link_title;
+  }
+
+
+  /**
+   * {@inheritdoc}
+   */
+  public function build() {
+    // $config = $this->getConfiguration();
+    $build = [];
+    $node = \Drupal::routeMatch()->getParameter('node');
+    if ($node instanceof \Drupal\node\Entity\Node) {
+      // check if programme
+      if($node->bundle() == 'programme'){
+        // if yes get id
+        // todo set the hardcoded nid number as a parameter somewhere
+        $nid = $node->id() == 6 ? $node->id() : false;
+      }
+
+      if($nid){
+        $title = "EXODE URBAIN";
+        $url = Url::fromRoute('entity.node.canonical');
+        // todo make the the hardcoded target nid as a parameter somewhere (recorded on the node ?)
+        $url->setRouteParameter("node", 878);
+        $url->setOption('attributes', array("class"=>array('prog-exodeurbain-link')));
+        $build['prog_exodeurbain_link'] = array(
+          '#title' => $title,
+          '#type' => 'link',
+          '#url' => $url
+        );
+      }
+    }
+    return $build;
+  }
+
+}

File diff suppressed because it is too large
+ 0 - 0
web/themes/custom/popsu/assets/css/styles.min.css


+ 2 - 1
web/themes/custom/popsu/sass/pages/_programme.scss

@@ -439,7 +439,8 @@
         left: 0;
         width: 22%;
         padding: 1rem 1.5rem ;
-        .prog-ressources-link{
+        .prog-ressources-link,
+        .prog-exodeurbain-link{
             font-family: "duke";
             font-size: $font-large;
             cursor: pointer;

Some files were not shown because too many files changed in this diff