Skip to main content
added 12 characters in body
Source Link
berramou
  • 7.3k
  • 2
  • 13
  • 31

We are using the Sitemap module (https://www.drupal.org/project/sitemapSitemap) module for creating a sitemap generated from three menus (Footer, Main nav and a 3rd arbitrary one).

In the main nav we have a placeholder LI element which we use to insert a view.

In the sitemap template we need to replace this placeholder with some content without affecting the main nav.

In the sitemap overridden template where {{ item.content }} normally appears I tried replacing with the following:

{{ item.content|replace('>LRGPH_BRANCHES_BY_SERVICE<', ('>' ~ allBranches ~ '<')) }}

Note: allBranches is a concatenation of the output of 4 views (Essentially pure HTML)

but Twig/Drupal seems to have issue with this as I get an error, as per below:

Warning: strtr() expects parameter 1 to be string, array given in twig_replace_filter() (line 521 of /var/www/vendor/twig/twig/src/Extension/CoreExtension.php).
twig_replace_filter(Array, '&gt;LRGPH_BRANCHES_BY_SERVICE&lt;', '&gt;<ul>

Warning: strtr() expects parameter 1 to be string, array given in twig_replace_filter() (line 521 of /var/www/vendor/twig/twig/src/Extension/CoreExtension.php). twig_replace_filter(Array, '>LRGPH_BRANCHES_BY_SERVICE<', '>

I next tried using the contributed modules hook, namely function TEMPLATE_preprocess_sitemap(&$variables) but although I can see the HTML output of the sitemap I cannot change it using this as far as I can tell.

Is there any way to achieve this change at all without altering the Main navigation?

We are using the Sitemap module (https://www.drupal.org/project/sitemap) for creating a sitemap generated from three menus (Footer, Main nav and a 3rd arbitrary one).

In the main nav we have a placeholder LI element which we use to insert a view.

In the sitemap template we need to replace this placeholder with some content without affecting the main nav.

In the sitemap overridden template where {{ item.content }} normally appears I tried replacing with the following:

{{ item.content|replace('>LRGPH_BRANCHES_BY_SERVICE<', ('>' ~ allBranches ~ '<')) }}

Note: allBranches is a concatenation of the output of 4 views (Essentially pure HTML)

but Twig/Drupal seems to have issue with this as I get an error, as per below:

Warning: strtr() expects parameter 1 to be string, array given in twig_replace_filter() (line 521 of /var/www/vendor/twig/twig/src/Extension/CoreExtension.php).
twig_replace_filter(Array, '&gt;LRGPH_BRANCHES_BY_SERVICE&lt;', '&gt;<ul>

I next tried using the contributed modules hook, namely function TEMPLATE_preprocess_sitemap(&$variables) but although I can see the HTML output of the sitemap I cannot change it using this as far as I can tell.

Is there any way to achieve this change at all without altering the Main navigation?

We are using the Sitemap module for creating a sitemap generated from three menus (Footer, Main nav and a 3rd arbitrary one).

In the main nav we have a placeholder LI element which we use to insert a view.

In the sitemap template we need to replace this placeholder with some content without affecting the main nav.

In the sitemap overridden template where {{ item.content }} normally appears I tried replacing with the following:

{{ item.content|replace('>LRGPH_BRANCHES_BY_SERVICE<', ('>' ~ allBranches ~ '<')) }}

Note: allBranches is a concatenation of the output of 4 views (Essentially pure HTML)

but Twig/Drupal seems to have issue with this as I get an error, as per below:

Warning: strtr() expects parameter 1 to be string, array given in twig_replace_filter() (line 521 of /var/www/vendor/twig/twig/src/Extension/CoreExtension.php). twig_replace_filter(Array, '>LRGPH_BRANCHES_BY_SERVICE<', '>

I next tried using the contributed modules hook, namely function TEMPLATE_preprocess_sitemap(&$variables) but although I can see the HTML output of the sitemap I cannot change it using this as far as I can tell.

Is there any way to achieve this change at all without altering the Main navigation?

Source Link
John Cogan
  • 334
  • 5
  • 22

Changing a menu link used in the sitemap module but not in main nav

We are using the Sitemap module (https://www.drupal.org/project/sitemap) for creating a sitemap generated from three menus (Footer, Main nav and a 3rd arbitrary one).

In the main nav we have a placeholder LI element which we use to insert a view.

In the sitemap template we need to replace this placeholder with some content without affecting the main nav.

In the sitemap overridden template where {{ item.content }} normally appears I tried replacing with the following:

{{ item.content|replace('>LRGPH_BRANCHES_BY_SERVICE<', ('>' ~ allBranches ~ '<')) }}

Note: allBranches is a concatenation of the output of 4 views (Essentially pure HTML)

but Twig/Drupal seems to have issue with this as I get an error, as per below:

Warning: strtr() expects parameter 1 to be string, array given in twig_replace_filter() (line 521 of /var/www/vendor/twig/twig/src/Extension/CoreExtension.php).
twig_replace_filter(Array, '&gt;LRGPH_BRANCHES_BY_SERVICE&lt;', '&gt;<ul>

I next tried using the contributed modules hook, namely function TEMPLATE_preprocess_sitemap(&$variables) but although I can see the HTML output of the sitemap I cannot change it using this as far as I can tell.

Is there any way to achieve this change at all without altering the Main navigation?