-
Notifications
You must be signed in to change notification settings - Fork 10
Cookbook: Dealing with titles longer than 255 characters
Fedora Commons enforces a maximum length of 255 characters on its object labels. In Islandora, the label comes from the MODS <title>
element. When an object whose label exceeds 255 characters is ingested, Islandora silently truncates it at the 255th character.
To work around this, you can use a Twig template via the MIK InsertXmlFromTemplate metadata manipulator to truncate the length of the value used in the MODS <title>
element and add an ellipsis in the title a few characters short of 255:
{% if Title|length < 256 %}
<titleInfo>
<title>{{ Title|trim }}</title>
</titleInfo>
{% else %}
<titleInfo>
<title>{{ Title|TwigTruncate(200) | trim }} [...]</title>
</titleInfo>
{% endif %}
The InsertXmlFromTemplate manipulator provides a Twig extension to truncate a string at the nearest word boundary, so you don't get half-words at the end of your title.
Content on the Move to Islandora Kit wiki is licensed under a Creative Commons Attribution 4.0 International License.