map translation
This commit is contained in:
parent
d740d58c0b
commit
788f00a603
|
@ -21,6 +21,8 @@ class SitesMap extends BlockBase {
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function build() {
|
public function build() {
|
||||||
|
$language = \Drupal::languageManager()->getCurrentLanguage()->getId();
|
||||||
|
|
||||||
$return = null;
|
$return = null;
|
||||||
|
|
||||||
$allSites = \Drupal::entityTypeManager()->getStorage('node')
|
$allSites = \Drupal::entityTypeManager()->getStorage('node')
|
||||||
|
@ -39,12 +41,14 @@ class SitesMap extends BlockBase {
|
||||||
|
|
||||||
|
|
||||||
foreach($allSites as $index => $site){
|
foreach($allSites as $index => $site){
|
||||||
$title = $site->get('title')->getString();
|
// $title = $site->get('title')->getString();
|
||||||
$subtitle = $site->get('field_sous_titre')->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']]; // Passer 'absolute' à TRUE
|
||||||
$site_url = $site->toUrl('canonical', $link_options)->toString(); // URL absolue pour le data-url
|
$site_url = $site->toUrl('canonical', $link_options)->toString(); // URL absolue pour le data-url
|
||||||
$site_link_object = Link::createFromRoute("voir le site", 'entity.node.canonical', ['node' => $site->id()], $link_options);
|
$site_link_object = Link::createFromRoute(t("got to site"), 'entity.node.canonical', ['node' => $site->id()], $link_options);
|
||||||
$link = $site_link_object->toString()->getGeneratedLink();
|
$link = $site_link_object->toString()->getGeneratedLink();
|
||||||
|
|
||||||
$datacontent = htmlspecialchars("<strong>$title</strong><br>$subtitle<br>$link");
|
$datacontent = htmlspecialchars("<strong>$title</strong><br>$subtitle<br>$link");
|
||||||
|
|
Loading…
Reference in New Issue