- 🇨🇭Switzerland maenjuel
#20 does the trick for nodes, but when I visit /admin/content or a view where I display the node title, I get the following error:
AH01071: Got error 'PHP message: TypeError: preg_split(): Argument #2 ($subject) must be of type string, array given in [drupal root]/web/modules/contrib/typogrify/src/SmartyPants.php on line 1343 #0 [drupal root]/web/modules/contrib/typogrify/src/SmartyPants.php(1343): preg_split()\n#1 [drupal root]/web/modules/contrib/typogrify/src/SmartyPants.php(269): Drupal\\typogrify\\SmartyPants::tokenizeHtml()\n#2 [drupal root]/web/modules/contrib/typogrify/src/Typogrify.php(218): Drupal\\typogrify\\SmartyPants::process()\n#3 [drupal root]/web/modules/contrib/typogrify/src/TwigExtension/Typogrify.php(39): Drupal\\typogrify\\Typogrify::filter()\n#4 [drupal root]/web/sites/default/files/php/twig/63f28b52e004b_page-title.html.twig_nHmMQSGyX8r5q48osUipCs1t0/ho1qwEkSF0cd_ek5utcVkhFFL_JTTl_-qPCPhjoH3uU.php(53): Drupal\\typogrify\\TwigExtension\\Typogrify::filter()\n#5 /var/custome...', referer: [page I'm coming from]
- 🇮🇪Ireland lostcarpark
@maenjuel, here's what I'm currently using:
{% if title is iterable %} {{ title }} {% else %} {{ title | typogrify }} {% endif %}
Unfortunately, it doesn't typogrify the title on views, but at least it doesn't give errors.
Hoping to find a better solution.
- 🇨🇭Switzerland maenjuel
After posting here, I stumbled upon that solution as well as @lostcarpark. Indeed it does the trick. Thanks for getting back at me and documenting it for other people who might encounter the same problem.
For views, typogrify could be applied in specific views templates, i.e. like this
{{ fields.title.content|typogrify }}
- 🇮🇪Ireland lostcarpark
I've found another solution for iterable fields.
Prefixing the
typogrify
filter with therender
filter forces all of the values to be combined into a single value.It can be used like this:
{{ title | render | typogrify }}