mission photographique
This commit is contained in:
		@@ -57,7 +57,7 @@ variant_settings:
 | 
			
		||||
      items_per_page: none
 | 
			
		||||
      exposed: {  }
 | 
			
		||||
      region: first
 | 
			
		||||
      weight: -1
 | 
			
		||||
      weight: 0
 | 
			
		||||
      uuid: 2ca2f1a3-98b4-41bf-bb67-e17fdd93f1f2
 | 
			
		||||
    4fc90a5b-8a2d-4f21-9718-e65b9982d59a:
 | 
			
		||||
      id: 'views_block:programme_toc-block_4'
 | 
			
		||||
@@ -102,7 +102,7 @@ variant_settings:
 | 
			
		||||
      provider: popsu_link_block
 | 
			
		||||
      context_mapping: {  }
 | 
			
		||||
      region: first
 | 
			
		||||
      weight: 2
 | 
			
		||||
      weight: 3
 | 
			
		||||
      uuid: 9c5741a0-e8e2-4895-88a7-c36d3825e33c
 | 
			
		||||
      link_title: Ressources
 | 
			
		||||
    c80f54a0-8f21-4c56-8341-eab59b009329:
 | 
			
		||||
@@ -142,7 +142,7 @@ variant_settings:
 | 
			
		||||
      items_per_page: none
 | 
			
		||||
      exposed: {  }
 | 
			
		||||
      region: first
 | 
			
		||||
      weight: 0
 | 
			
		||||
      weight: 1
 | 
			
		||||
      uuid: 9f70ea8b-3a5f-4e48-97b0-2b3d5e5e7d03
 | 
			
		||||
    232f18ef-a92c-451e-b917-e436b6cbc195:
 | 
			
		||||
      id: 'views_block:programme_toc-block_9'
 | 
			
		||||
@@ -154,7 +154,7 @@ variant_settings:
 | 
			
		||||
      items_per_page: none
 | 
			
		||||
      exposed: {  }
 | 
			
		||||
      region: first
 | 
			
		||||
      weight: -2
 | 
			
		||||
      weight: -1
 | 
			
		||||
      uuid: 232f18ef-a92c-451e-b917-e436b6cbc195
 | 
			
		||||
    b564145a-2058-4710-8204-50569d4f0bf0:
 | 
			
		||||
      id: 'views_block:programme_toc-block_13'
 | 
			
		||||
@@ -166,7 +166,7 @@ variant_settings:
 | 
			
		||||
      items_per_page: none
 | 
			
		||||
      exposed: {  }
 | 
			
		||||
      region: first
 | 
			
		||||
      weight: -3
 | 
			
		||||
      weight: -2
 | 
			
		||||
      uuid: b564145a-2058-4710-8204-50569d4f0bf0
 | 
			
		||||
    b84fe2f8-7c0b-4976-aa63-d8dc5ae66fc0:
 | 
			
		||||
      id: 'views_block:programme_toc-block_16'
 | 
			
		||||
@@ -182,7 +182,7 @@ variant_settings:
 | 
			
		||||
          type: node_nid
 | 
			
		||||
          value: '[node:nid]'
 | 
			
		||||
      region: first
 | 
			
		||||
      weight: 1
 | 
			
		||||
      weight: 2
 | 
			
		||||
      uuid: b84fe2f8-7c0b-4976-aa63-d8dc5ae66fc0
 | 
			
		||||
    532e0e26-eab4-476f-a964-fd68221d5619:
 | 
			
		||||
      id: prog_exode_urbain_link
 | 
			
		||||
@@ -229,6 +229,20 @@ variant_settings:
 | 
			
		||||
      region: first
 | 
			
		||||
      weight: -6
 | 
			
		||||
      uuid: 63e18587-3199-4058-93e3-7af297464f84
 | 
			
		||||
    025ff2a8-f64b-42ee-a7be-98fb7fd0caa0:
 | 
			
		||||
      id: prog_mission_photo_link
 | 
			
		||||
      label: 'Mission Photographique'
 | 
			
		||||
      label_display: '0'
 | 
			
		||||
      provider: popsu_link_block
 | 
			
		||||
      context_mapping: {  }
 | 
			
		||||
      region: first
 | 
			
		||||
      weight: -3
 | 
			
		||||
      uuid: 025ff2a8-f64b-42ee-a7be-98fb7fd0caa0
 | 
			
		||||
      css_classes:
 | 
			
		||||
        - ''
 | 
			
		||||
      html_id: ''
 | 
			
		||||
      css_styles: ''
 | 
			
		||||
      link_title: 'Mission Photographique'
 | 
			
		||||
  page_title: ''
 | 
			
		||||
  layout: layout_threecol_25_50_25
 | 
			
		||||
  layout_settings:
 | 
			
		||||
@@ -236,7 +250,8 @@ variant_settings:
 | 
			
		||||
  builder: standard
 | 
			
		||||
  storage_type: page_manager
 | 
			
		||||
  storage_id: node-panels_variant-0
 | 
			
		||||
  css_classes: {  }
 | 
			
		||||
  css_classes:
 | 
			
		||||
    - ''
 | 
			
		||||
  html_id: ''
 | 
			
		||||
  css_styles: ''
 | 
			
		||||
page: node
 | 
			
		||||
 
 | 
			
		||||
@@ -398,6 +398,52 @@ display:
 | 
			
		||||
            default_group: All
 | 
			
		||||
            default_group_multiple: {  }
 | 
			
		||||
            group_items: {  }
 | 
			
		||||
        nid_2:
 | 
			
		||||
          id: nid_2
 | 
			
		||||
          table: node_field_data
 | 
			
		||||
          field: nid
 | 
			
		||||
          relationship: none
 | 
			
		||||
          group_type: group
 | 
			
		||||
          admin_label: ''
 | 
			
		||||
          entity_type: node
 | 
			
		||||
          entity_field: nid
 | 
			
		||||
          plugin_id: numeric
 | 
			
		||||
          operator: '='
 | 
			
		||||
          value:
 | 
			
		||||
            min: ''
 | 
			
		||||
            max: ''
 | 
			
		||||
            value: '1162'
 | 
			
		||||
          group: 2
 | 
			
		||||
          exposed: false
 | 
			
		||||
          expose:
 | 
			
		||||
            operator_id: ''
 | 
			
		||||
            label: ''
 | 
			
		||||
            description: ''
 | 
			
		||||
            use_operator: false
 | 
			
		||||
            operator: ''
 | 
			
		||||
            operator_limit_selection: false
 | 
			
		||||
            operator_list: {  }
 | 
			
		||||
            identifier: ''
 | 
			
		||||
            required: false
 | 
			
		||||
            remember: false
 | 
			
		||||
            multiple: false
 | 
			
		||||
            remember_roles:
 | 
			
		||||
              authenticated: authenticated
 | 
			
		||||
            min_placeholder: ''
 | 
			
		||||
            max_placeholder: ''
 | 
			
		||||
            placeholder: ''
 | 
			
		||||
          is_grouped: false
 | 
			
		||||
          group_info:
 | 
			
		||||
            label: ''
 | 
			
		||||
            description: ''
 | 
			
		||||
            identifier: ''
 | 
			
		||||
            optional: true
 | 
			
		||||
            widget: select
 | 
			
		||||
            multiple: false
 | 
			
		||||
            remember: false
 | 
			
		||||
            default_group: All
 | 
			
		||||
            default_group_multiple: {  }
 | 
			
		||||
            group_items: {  }
 | 
			
		||||
      filter_groups:
 | 
			
		||||
        operator: AND
 | 
			
		||||
        groups:
 | 
			
		||||
@@ -646,6 +692,52 @@ display:
 | 
			
		||||
            default_group: All
 | 
			
		||||
            default_group_multiple: {  }
 | 
			
		||||
            group_items: {  }
 | 
			
		||||
        nid_2:
 | 
			
		||||
          id: nid_2
 | 
			
		||||
          table: node_field_data
 | 
			
		||||
          field: nid
 | 
			
		||||
          relationship: none
 | 
			
		||||
          group_type: group
 | 
			
		||||
          admin_label: ''
 | 
			
		||||
          entity_type: node
 | 
			
		||||
          entity_field: nid
 | 
			
		||||
          plugin_id: numeric
 | 
			
		||||
          operator: '!='
 | 
			
		||||
          value:
 | 
			
		||||
            min: ''
 | 
			
		||||
            max: ''
 | 
			
		||||
            value: '1162'
 | 
			
		||||
          group: 1
 | 
			
		||||
          exposed: false
 | 
			
		||||
          expose:
 | 
			
		||||
            operator_id: ''
 | 
			
		||||
            label: ''
 | 
			
		||||
            description: ''
 | 
			
		||||
            use_operator: false
 | 
			
		||||
            operator: ''
 | 
			
		||||
            operator_limit_selection: false
 | 
			
		||||
            operator_list: {  }
 | 
			
		||||
            identifier: ''
 | 
			
		||||
            required: false
 | 
			
		||||
            remember: false
 | 
			
		||||
            multiple: false
 | 
			
		||||
            remember_roles:
 | 
			
		||||
              authenticated: authenticated
 | 
			
		||||
            min_placeholder: ''
 | 
			
		||||
            max_placeholder: ''
 | 
			
		||||
            placeholder: ''
 | 
			
		||||
          is_grouped: false
 | 
			
		||||
          group_info:
 | 
			
		||||
            label: ''
 | 
			
		||||
            description: ''
 | 
			
		||||
            identifier: ''
 | 
			
		||||
            optional: true
 | 
			
		||||
            widget: select
 | 
			
		||||
            multiple: false
 | 
			
		||||
            remember: false
 | 
			
		||||
            default_group: All
 | 
			
		||||
            default_group_multiple: {  }
 | 
			
		||||
            group_items: {  }
 | 
			
		||||
      filter_groups:
 | 
			
		||||
        operator: AND
 | 
			
		||||
        groups:
 | 
			
		||||
 
 | 
			
		||||
@@ -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_mission_photo_link",
 | 
			
		||||
 *  admin_label = @Translation("Prog mission photographique link"),
 | 
			
		||||
 * )
 | 
			
		||||
 */
 | 
			
		||||
class ProgMissionPhotoLink 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'] : "Mission Photographique",
 | 
			
		||||
      '#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 = "MISSION PHOTOGRAPHIQUE";
 | 
			
		||||
        $url = Url::fromRoute('entity.node.canonical');
 | 
			
		||||
        // todo make the the hardcoded target nid as a parameter somewhere (recorded on the node ?)
 | 
			
		||||
        $url->setRouteParameter("node", 1162);
 | 
			
		||||
        $url->setOption('attributes', array("class"=>array('prog-missionphoto-link')));
 | 
			
		||||
        $build['prog_missionphoto_link'] = array(
 | 
			
		||||
          '#title' => $title,
 | 
			
		||||
          '#type' => 'link',
 | 
			
		||||
          '#url' => $url
 | 
			
		||||
        );
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    return $build;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@@ -445,7 +445,8 @@
 | 
			
		||||
        padding: 1rem 1.5rem ;
 | 
			
		||||
        a.prog-palpite-link,
 | 
			
		||||
        a.prog-ressources-link,
 | 
			
		||||
        a.prog-exodeurbain-link{
 | 
			
		||||
        a.prog-exodeurbain-link,
 | 
			
		||||
        a.prog-missionphoto-link{
 | 
			
		||||
            text-transform: uppercase;
 | 
			
		||||
            font-family: "duke";
 | 
			
		||||
            font-size: $font-large;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user