custom map language aware links url; patched core for image field link language aware
This commit is contained in:
parent
bfb94ef05b
commit
5a48eee4ef
|
@ -126,6 +126,9 @@
|
|||
"merge-extra": true
|
||||
},
|
||||
"patches": {
|
||||
"drupal/core": {
|
||||
"Image field generates only default language URL when linking to corresponding entity. https://www.drupal.org/node/2645922?no_cache=1733132298":"https://www.drupal.org/files/issues/2021-03-15/2645922-45.patch"
|
||||
},
|
||||
"drupal/social_media_links":{
|
||||
"Replace Twitter with X https://www.drupal.org/project/social_media_links/issues/3384469": "https://www.drupal.org/files/issues/2023-09-12/social_media_links-change_twitter_to_x-3384469-7.patch"
|
||||
},
|
||||
|
|
|
@ -41,12 +41,14 @@ class SitesMap extends BlockBase {
|
|||
|
||||
|
||||
foreach($allSites as $index => $site){
|
||||
$langcode = \Drupal::languageManager()->getCurrentLanguage()->getId();
|
||||
|
||||
// $title = $site->get('title')->getString();
|
||||
$title = $site->hasTranslation($language) ? $site->getTranslation($language)->get('title')->getString() : $site->get('title')->getString();
|
||||
// $subtitle = $site->get('field_sous_titre')->getString();
|
||||
$subtitle = $site->hasTranslation($language) ? $site->getTranslation($language)->get('field_sous_titre')->getString() : $site->get('field_sous_titre')->getString();
|
||||
|
||||
$link_options = ['absolute' => TRUE, 'attributes' => ['class' => 'site-link']]; // Passer 'absolute' à TRUE
|
||||
$link_options = ['absolute' => TRUE, 'attributes' => ['class' => 'site-link'], 'language' => \Drupal::languageManager()->getLanguage($langcode)]; // Passer 'absolute' à TRUE
|
||||
$site_url = $site->toUrl('canonical', $link_options)->toString(); // URL absolue pour le data-url
|
||||
$site_link_object = Link::createFromRoute(t("got to site"), 'entity.node.canonical', ['node' => $site->id()], $link_options);
|
||||
$link = $site_link_object->toString()->getGeneratedLink();
|
||||
|
|
Loading…
Reference in New Issue