converted geofields to paragarphs, updated SiteMap.php

This commit is contained in:
Bachir Soussi Chiadmi 2025-01-27 13:11:17 +01:00
parent be90064f2a
commit d912155cd0
18 changed files with 437 additions and 255 deletions

View File

@ -11,7 +11,6 @@ dependencies:
- field.field.node.projet.field_diaporama
- field.field.node.projet.field_intro
- field.field.node.projet.field_legende_carte
- field.field.node.projet.field_libelles_carte
- field.field.node.projet.field_liens
- field.field.node.projet.field_localisation_textuel
- field.field.node.projet.field_pieces_jointes
@ -27,7 +26,6 @@ dependencies:
- field_group
- file
- image
- leaflet
- link
- paragraphs
- path
@ -46,7 +44,7 @@ third_party_settings:
label: Tabs
region: content
parent_name: ''
weight: 3
weight: 1
format_type: tabs
format_settings:
classes: ''
@ -59,10 +57,10 @@ third_party_settings:
children:
- field_sous_titre
- field_localisation_textuel
- field_intro
- field_texte
- field_chiffres_clefs
- field_chronologie
- field_intro
label: Contenus
region: content
parent_name: group_tabs
@ -78,9 +76,8 @@ third_party_settings:
required_fields: true
group_carte:
children:
- field_carte
- field_libelles_carte
- field_legende_carte
- field_carte
label: carte
region: content
parent_name: group_tabs
@ -136,7 +133,7 @@ third_party_settings:
label: Details
region: content
parent_name: ''
weight: 4
weight: 2
format_type: details_sidebar
format_settings:
classes: ''
@ -212,69 +209,22 @@ content:
placeholder: ''
third_party_settings: { }
field_carte:
type: leaflet_widget_default
weight: 3
type: paragraphs
weight: 4
region: content
settings:
map:
leaflet_map: 'OSM Mapnik'
height: 400
auto_center: 1
map_position:
force: true
center:
lat: 46.751944
lon: 2.416667
zoomControlPosition: topleft
zoom: 5
minZoom: 1
maxZoom: 18
zoomFiner: 0
scroll_zoom_enabled: 1
input:
show: true
readonly: false
toolbar:
position: topright
marker: defaultMarker
drawPolyline: true
drawRectangle: true
drawPolygon: true
drawCircle: false
drawText: false
editMode: false
dragMode: false
cutPolygon: false
removalMode: false
rotateMode: false
reset_map:
control: false
options: '{"position":"topleft","title":"Reset View"}'
map_scale:
control: false
options: '{"position":"bottomright","maxWidth":100,"metric":true,"imperial":false,"updateWhenIdle":false}'
fullscreen:
control: false
options: '{"position":"topleft","pseudoFullscreen":false}'
path: '{"color":"#3388ff","opacity":"1.0","stroke":true,"weight":3,"fill":"depends","fillColor":"*","fillOpacity":"0.2","radius":"6"}'
locate:
control: false
options: '{"position":"topright","setView":"untilPanOrZoom","returnToPrevBounds":true,"keepCurrentZoomLevel":true,"strings":{"title":"Locate my position"}}'
automatic: false
geocoder:
control: false
settings:
position: topright
input_size: 20
providers: { }
min_terms: 4
delay: 800
zoom: 16
popup: false
options: ''
geometry_validation: 0
feature_properties:
values: ''
title: Paragraphe
title_plural: Paragraphs
edit_mode: open
closed_mode: summary
autocollapse: none
closed_mode_threshold: 0
add_mode: dropdown
form_display_mode: default
default_paragraph_type: ''
features:
collapse_edit_all: collapse_edit_all
duplicate: duplicate
third_party_settings: { }
field_chiffres_clefs:
type: paragraphs
@ -348,26 +298,12 @@ content:
third_party_settings: { }
field_legende_carte:
type: text_textarea
weight: 32
weight: 3
region: content
settings:
rows: 5
placeholder: ''
third_party_settings: { }
field_libelles_carte:
type: string_textfield
weight: 4
region: content
settings:
size: 60
placeholder: 'Un libellé par repère ou zone'
third_party_settings:
maxlength:
maxlength_js: null
maxlength_js_label: 'Contenu limité à @limit caractères, restant : <strong>@remaining</strong>'
maxlength_js_enforce: false
advanced_text_formatter:
show_token_tree: 0
field_liens:
type: link_default
weight: 5

View File

@ -0,0 +1,99 @@
uuid: c23cab46-cadb-4b78-a0f1-48212974f8a5
langcode: fr
status: true
dependencies:
config:
- field.field.paragraph.geofield_projet.field_carte
- field.field.paragraph.geofield_projet.field_libele
- field.field.paragraph.geofield_projet.field_principal
- paragraphs.paragraphs_type.geofield_projet
module:
- leaflet
id: paragraph.geofield_projet.default
targetEntityType: paragraph
bundle: geofield_projet
mode: default
content:
field_carte:
type: leaflet_widget_default
weight: 1
region: content
settings:
map:
leaflet_map: 'OSM Mapnik'
height: 400
auto_center: 1
map_position:
force: false
center:
lat: 0.0
lon: 0.0
zoomControlPosition: topleft
zoom: 5
minZoom: 1
maxZoom: 18
zoomFiner: 0
scroll_zoom_enabled: 1
input:
show: true
readonly: false
toolbar:
position: topright
marker: defaultMarker
drawPolyline: true
drawRectangle: true
drawPolygon: true
drawCircle: false
drawText: false
editMode: true
dragMode: true
cutPolygon: false
removalMode: true
rotateMode: false
reset_map:
control: false
options: '{"position": "topleft", "title": "Reset View"}'
map_scale:
control: false
options: '{"position":"bottomright","maxWidth":100,"metric":true,"imperial":false,"updateWhenIdle":false}'
fullscreen:
control: false
options: '{"position":"topleft","pseudoFullscreen":false}'
path: '{"color":"#3388ff","opacity":"1.0","stroke":true,"weight":3,"fill":"depends","fillColor":"*","fillOpacity":"0.2","radius":"6"}'
locate:
control: false
options: '{"position": "topright", "setView": "untilPanOrZoom", "returnToPrevBounds":true, "keepCurrentZoomLevel": true, "strings": {"title": "Locate my position"}}'
automatic: false
geocoder:
control: false
settings:
position: topright
input_size: 20
providers: { }
min_terms: 4
delay: 800
zoom: 16
popup: false
options: ''
geometry_validation: false
feature_properties:
values: ''
third_party_settings: { }
field_libele:
type: string_textfield
weight: 2
region: content
settings:
size: 60
placeholder: ''
third_party_settings: { }
field_principal:
type: boolean_checkbox
weight: 0
region: content
settings:
display_label: true
third_party_settings: { }
hidden:
created: true
status: true

View File

@ -11,7 +11,6 @@ dependencies:
- field.field.node.projet.field_diaporama
- field.field.node.projet.field_intro
- field.field.node.projet.field_legende_carte
- field.field.node.projet.field_libelles_carte
- field.field.node.projet.field_liens
- field.field.node.projet.field_localisation_textuel
- field.field.node.projet.field_pieces_jointes
@ -25,7 +24,6 @@ dependencies:
module:
- entity_reference_revisions
- file
- geofield
- image
- link
- text
@ -44,13 +42,13 @@ content:
weight: 14
region: content
field_carte:
type: geofield_default
type: entity_reference_revisions_entity_view
label: above
settings:
output_format: wkt
output_escape: true
view_mode: default
link: ''
third_party_settings: { }
weight: 11
weight: 20
region: content
field_chiffres_clefs:
type: entity_reference_revisions_entity_view
@ -104,14 +102,6 @@ content:
third_party_settings: { }
weight: 19
region: content
field_libelles_carte:
type: string
label: above
settings:
link_to_entity: false
third_party_settings: { }
weight: 12
region: content
field_liens:
type: link
label: hidden

View File

@ -12,7 +12,6 @@ dependencies:
- field.field.node.projet.field_diaporama
- field.field.node.projet.field_intro
- field.field.node.projet.field_legende_carte
- field.field.node.projet.field_libelles_carte
- field.field.node.projet.field_liens
- field.field.node.projet.field_localisation_textuel
- field.field.node.projet.field_pieces_jointes
@ -28,7 +27,6 @@ dependencies:
- entity_reference_revisions
- file
- image_field_caption
- leaflet
- link
- text
- user
@ -37,100 +35,6 @@ targetEntityType: node
bundle: projet
mode: full
content:
field_carte:
type: leaflet_formatter_default
label: visually_hidden
settings:
multiple_map: false
leaflet_map: 'OSM Mapnik'
height: 400
height_unit: px
hide_empty_map: false
disable_wheel: false
gesture_handling: false
fitbounds_options: '{"padding":[0,0]}'
reset_map:
control: false
options: '{"position":"topleft","title":"Reset View"}'
map_scale:
control: false
options: '{"position":"bottomright","maxWidth":100,"metric":true,"imperial":false,"updateWhenIdle":false}'
locate:
control: false
options: '{"position":"topright","setView":"untilPanOrZoom","returnToPrevBounds":true,"keepCurrentZoomLevel":true,"strings":{"title":"Locate my position"}}'
automatic: false
leaflet_tooltip:
value: ''
options: '{"permanent":false,"direction":"center"}'
popup: false
popup_content: ''
leaflet_popup:
control: '0'
content: '[node:field_libelles_carte]'
options: '{"maxWidth":"300","minWidth":"50","autoPan":true}'
map_position:
force: false
center:
lat: 0.0
lon: 0.0
zoomControlPosition: topleft
zoom: 5
minZoom: 1
maxZoom: 18
zoomFiner: 0
icon:
iconType: marker
iconUrl: ''
shadowUrl: ''
className: ''
iconSize:
x: ''
'y': ''
iconAnchor:
x: ''
'y': ''
shadowSize:
x: ''
'y': ''
shadowAnchor:
x: ''
'y': ''
popupAnchor:
x: ''
'y': ''
html: '<div></div>'
html_class: leaflet-map-divicon
circle_marker_options: '{"radius":100,"color":"red","fillColor":"#f03","fillOpacity":0.5}'
leaflet_markercluster:
control: false
options: '{"spiderfyOnMaxZoom":true,"showCoverageOnHover":true,"removeOutsideVisibleBounds": false}'
excluded: ''
include_path: false
fullscreen:
control: false
options: '{"position":"topleft","pseudoFullscreen":false}'
path: '{"color":"#3388ff","opacity":"1.0","stroke":true,"weight":3,"fill":"depends","fillColor":"*","fillOpacity":"0.2","radius":"6"}'
feature_properties:
values: ''
geocoder:
control: false
settings:
autocomplete:
placeholder: 'Search Address'
title: 'Search an Address on the Map'
position: topright
input_size: 20
providers: { }
min_terms: 4
delay: 800
zoom: 16
popup: false
options: ''
map_lazy_load:
lazy_load: false
third_party_settings: { }
weight: 7
region: content
field_chiffres_clefs:
type: entity_reference_revisions_entity_view
label: visually_hidden
@ -183,14 +87,6 @@ content:
third_party_settings: { }
weight: 9
region: content
field_libelles_carte:
type: string
label: above
settings:
link_to_entity: false
third_party_settings: { }
weight: 8
region: content
field_liens:
type: link
label: visually_hidden
@ -254,6 +150,7 @@ content:
region: content
hidden:
field_actualites_liees: true
field_carte: true
field_poids: true
field_session: true
langcode: true

View File

@ -12,7 +12,6 @@ dependencies:
- field.field.node.projet.field_diaporama
- field.field.node.projet.field_intro
- field.field.node.projet.field_legende_carte
- field.field.node.projet.field_libelles_carte
- field.field.node.projet.field_liens
- field.field.node.projet.field_localisation_textuel
- field.field.node.projet.field_pieces_jointes
@ -52,7 +51,6 @@ hidden:
field_diaporama: true
field_intro: true
field_legende_carte: true
field_libelles_carte: true
field_liens: true
field_localisation_textuel: true
field_pieces_jointes: true

View File

@ -12,7 +12,6 @@ dependencies:
- field.field.node.projet.field_diaporama
- field.field.node.projet.field_intro
- field.field.node.projet.field_legende_carte
- field.field.node.projet.field_libelles_carte
- field.field.node.projet.field_liens
- field.field.node.projet.field_localisation_textuel
- field.field.node.projet.field_pieces_jointes
@ -77,7 +76,6 @@ hidden:
field_collectif_du_projet: true
field_intro: true
field_legende_carte: true
field_libelles_carte: true
field_liens: true
field_pieces_jointes: true
field_poids: true

View File

@ -0,0 +1,124 @@
uuid: 6e0e14d8-dc29-4d65-9f7f-5f510d33ce93
langcode: fr
status: true
dependencies:
config:
- field.field.paragraph.geofield_projet.field_carte
- field.field.paragraph.geofield_projet.field_libele
- field.field.paragraph.geofield_projet.field_principal
- paragraphs.paragraphs_type.geofield_projet
module:
- leaflet
id: paragraph.geofield_projet.default
targetEntityType: paragraph
bundle: geofield_projet
mode: default
content:
field_carte:
type: leaflet_formatter_default
label: hidden
settings:
multiple_map: false
leaflet_map: 'OSM Mapnik'
height: 400
height_unit: px
hide_empty_map: false
disable_wheel: false
gesture_handling: false
fitbounds_options: '{"padding":[0,0]}'
reset_map:
control: false
options: '{"position": "topleft", "title": "Reset View"}'
map_scale:
control: false
options: '{"position":"bottomright","maxWidth":100,"metric":true,"imperial":false,"updateWhenIdle":false}'
locate:
control: false
options: '{"position": "topright", "setView": "untilPanOrZoom", "returnToPrevBounds":true, "keepCurrentZoomLevel": true, "strings": {"title": "Locate my position"}}'
automatic: false
leaflet_tooltip:
value: ''
options: '{"permanent":false,"direction":"center"}'
popup: false
popup_content: ''
leaflet_popup:
control: ''
content: ''
options: '{"maxWidth":"300","minWidth":"50", "autoPan": true}'
value: ''
view_mode: full
map_position:
force: false
center:
lat: 0.0
lon: 0.0
zoomControlPosition: topleft
zoom: 5
minZoom: 1
maxZoom: 18
zoomFiner: 0
weight: '0'
icon:
iconType: marker
iconUrl: ''
shadowUrl: ''
className: ''
iconSize:
x: null
'y': null
iconAnchor:
x: null
'y': null
shadowSize:
x: null
'y': null
shadowAnchor:
x: null
'y': null
popupAnchor:
x: null
'y': null
html: '<div></div>'
html_class: leaflet-map-divicon
circle_marker_options: '{"radius": 100, "color": "red", "fillColor": "#f03", "fillOpacity": 0.5}'
leaflet_markercluster:
control: false
options: '{"spiderfyOnMaxZoom":true,"showCoverageOnHover":true,"removeOutsideVisibleBounds": false}'
excluded: ''
include_path: false
fullscreen:
control: false
options: '{"position":"topleft","pseudoFullscreen":false}'
path: '{"color":"#3388ff","opacity":"1.0","stroke":true,"weight":3,"fill":"depends","fillColor":"*","fillOpacity":"0.2","radius":"6"}'
feature_properties:
values: ''
geocoder:
control: false
settings:
autocomplete:
placeholder: 'Search Address'
title: 'Search an Address on the Map'
position: topright
input_size: 20
providers: { }
min_terms: 4
delay: 800
zoom: 16
popup: false
options: ''
map_lazy_load:
lazy_load: false
third_party_settings: { }
weight: 0
region: content
field_libele:
type: string
label: hidden
settings:
link_to_entity: false
third_party_settings: { }
weight: 1
region: content
hidden:
field_principal: true
search_api_excerpt: true

View File

@ -1,12 +1,13 @@
uuid: ef45349c-ea3f-4769-92fe-dd544c52ce0f
uuid: ef45c217-f669-4116-8b44-97bd898619cf
langcode: fr
status: true
dependencies:
config:
- field.storage.node.field_carte
- node.type.projet
- paragraphs.paragraphs_type.geofield_projet
module:
- geofield
- entity_reference_revisions
id: node.projet.field_carte
field_name: field_carte
entity_type: node
@ -17,5 +18,29 @@ required: false
translatable: false
default_value: { }
default_value_callback: ''
settings: { }
field_type: geofield
settings:
handler: 'default:paragraph'
handler_settings:
target_bundles:
geofield_projet: geofield_projet
negate: 0
target_bundles_drag_drop:
chiffre_clef:
weight: 8
enabled: false
chronologie:
weight: 9
enabled: false
collectif_projet:
weight: 10
enabled: false
geofield_projet:
weight: 7
enabled: true
intertitre_texte:
weight: 11
enabled: false
membre_equipe:
weight: 12
enabled: false
field_type: entity_reference_revisions

View File

@ -1,19 +0,0 @@
uuid: 62b4f37c-e8b3-4084-a17e-525f51421f11
langcode: fr
status: true
dependencies:
config:
- field.storage.node.field_libelles_carte
- node.type.projet
id: node.projet.field_libelles_carte
field_name: field_libelles_carte
entity_type: node
bundle: projet
label: libelles_carte
description: ''
required: false
translatable: false
default_value: { }
default_value_callback: ''
settings: { }
field_type: string

View File

@ -0,0 +1,21 @@
uuid: 61590666-a4d6-46f7-87a6-9232dad72908
langcode: fr
status: true
dependencies:
config:
- field.storage.paragraph.field_carte
- paragraphs.paragraphs_type.geofield_projet
module:
- geofield
id: paragraph.geofield_projet.field_carte
field_name: field_carte
entity_type: paragraph
bundle: geofield_projet
label: Carte
description: ''
required: false
translatable: false
default_value: { }
default_value_callback: ''
settings: { }
field_type: geofield

View File

@ -0,0 +1,19 @@
uuid: a7bd1c91-48b4-4f7f-8d51-7bd563a6c81e
langcode: fr
status: true
dependencies:
config:
- field.storage.paragraph.field_libele
- paragraphs.paragraphs_type.geofield_projet
id: paragraph.geofield_projet.field_libele
field_name: field_libele
entity_type: paragraph
bundle: geofield_projet
label: Libélé
description: ''
required: false
translatable: false
default_value: { }
default_value_callback: ''
settings: { }
field_type: string

View File

@ -0,0 +1,23 @@
uuid: 75e5c9a2-a9af-4ac0-b98a-e30623a3f940
langcode: fr
status: true
dependencies:
config:
- field.storage.paragraph.field_principal
- paragraphs.paragraphs_type.geofield_projet
id: paragraph.geofield_projet.field_principal
field_name: field_principal
entity_type: paragraph
bundle: geofield_projet
label: Principal
description: ''
required: false
translatable: false
default_value:
-
value: 0
default_value_callback: ''
settings:
on_label: oui
off_label: non
field_type: boolean

View File

@ -1,17 +1,18 @@
uuid: b67c3939-1668-44af-9284-04aa909b60be
uuid: 8d023e8b-b8ba-4de5-a688-b9c39647d78f
langcode: fr
status: true
dependencies:
module:
- geofield
- entity_reference_revisions
- node
- paragraphs
id: node.field_carte
field_name: field_carte
entity_type: node
type: geofield
type: entity_reference_revisions
settings:
backend: geofield_backend_default
module: geofield
target_type: paragraph
module: entity_reference_revisions
locked: false
cardinality: -1
translatable: true

View File

@ -0,0 +1,20 @@
uuid: f964953a-8d0b-4519-80e1-a7c0f1993f7d
langcode: fr
status: true
dependencies:
module:
- geofield
- paragraphs
id: paragraph.field_carte
field_name: field_carte
entity_type: paragraph
type: geofield
settings:
backend: geofield_backend_default
module: geofield
locked: false
cardinality: 1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false

View File

@ -1,12 +1,12 @@
uuid: fbdd3f5f-1614-4c89-bfae-983cdea74493
uuid: 1e47a81a-0d7c-41a8-8f4c-5ee00a4d5d3a
langcode: fr
status: true
dependencies:
module:
- node
id: node.field_libelles_carte
field_name: field_libelles_carte
entity_type: node
- paragraphs
id: paragraph.field_libele
field_name: field_libele
entity_type: paragraph
type: string
settings:
max_length: 255
@ -14,7 +14,7 @@ settings:
is_ascii: false
module: core
locked: false
cardinality: -1
cardinality: 1
translatable: true
indexes: { }
persist_with_no_fields: false

View File

@ -0,0 +1,18 @@
uuid: 32ff69db-9da5-4d96-913d-b66b72b064c4
langcode: fr
status: true
dependencies:
module:
- paragraphs
id: paragraph.field_principal
field_name: field_principal
entity_type: paragraph
type: boolean
settings: { }
module: core
locked: false
cardinality: 1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false

View File

@ -0,0 +1,10 @@
uuid: 1d2b719d-2cd0-4376-8c6f-13fb3c392f27
langcode: fr
status: true
dependencies: { }
id: geofield_projet
label: 'geofield projet'
icon_uuid: null
icon_default: null
description: ''
behavior_plugins: { }

View File

@ -7,6 +7,7 @@ use Drupal\Core\Block\Attribute\Block;
// use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\Link;
use Drupal\Core\Render\Markup;
use Drupal\paragraphs\Entity\Paragraph;
/**
* Provides a 'Sites Map' Block.
@ -32,25 +33,46 @@ class SitesMap extends BlockBase {
$sites_paths = "";
foreach($allSites as $index => $site){
$title = $site->get('title')->getString();
$subtitle = $site->get('field_sous_titre')->getString();
$place = $site->get('field_localisation_textuel')->getString();
// Check if the node has the paragraph field and it's not empty.
if ($site->hasField('field_carte') && !$site->get('field_carte')->isEmpty()) {
// Iterate through the referenced paragraph entities.
foreach ($site->get('field_carte')->referencedEntities() as $carte_paragraph) {
if ($carte_paragraph instanceof Paragraph) {
$geofield = $carte_paragraph->get('field_carte');
$principal = $carte_paragraph->get('field_principal')->value;
$link_options = ['absolute' => FALSE, 'attributes' => ['class' => 'site-link']];
$site_link_object = Link::createFromRoute("voir le site", 'entity.node.canonical', ['node' => $site->id()], $link_options);
$href = $site_link_object->getUrl()->toString();
if ($geofield && $principal) {
$geofield = $site->get('field_carte')->get(0);
$lon = $geofield->lon;
$lat = $geofield->lat;
$title = $site->get('title')->getString();
$subtitle = $site->get('field_sous_titre')->getString();
$place = $site->get('field_localisation_textuel')->getString();
$link_options = ['absolute' => FALSE, 'attributes' => ['class' => 'site-link']];
$site_link_object = Link::createFromRoute("voir le site", 'entity.node.canonical', ['node' => $site->id()], $link_options);
$href = $site_link_object->getUrl()->toString();
$lon = $geofield->lon;
$lat = $geofield->lat;
$svg_template_path = DRUPAL_ROOT . '/modules/custom/erable_mod/assets/svg/feuille.svg';
$svg_template= file_get_contents($svg_template_path);
$sites_paths .= str_replace(
['$index', '$lon', '$lat', '$href', '$title', '$place'],
[$index, $lon, $lat, $href, $title, $place],
$svg_template
);
$svg_template_path = DRUPAL_ROOT . '/modules/custom/erable_mod/assets/svg/feuille.svg';
$svg_template= file_get_contents($svg_template_path);
$sites_paths .= str_replace(
['$index', '$lon', '$lat', '$href', '$title', '$place'],
[$index, $lon, $lat, $href, $title, $place],
$svg_template
);
break;
}
}
}
}
}
$return = [