Typogrify in title

Created on 14 January 2009, almost 16 years ago
Updated 2 June 2023, over 1 year ago

Hi,

I wonder if and how it would be possible to use the filter for the title of a node. Has anyone wrote a hook or something to get this to work?

Thanks in advance... Tom

Feature request
Status

Closed: won't fix

Version

1.0

Component

Miscellaneous

Created by

🇩🇪Germany TomMynd

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇨🇭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 the render filter forces all of the values to be combined into a single value.

    It can be used like this: {{ title | render | typogrify }}

Production build 0.71.5 2024