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?