Documentation · ViewHelper reference

XSD schema file | vhs master

Format / SanitizeStringViewHelper

URL text segment sanitizer. Sanitizes the content into a valid URL segment value which is usable in an URL without further processing. For example, the text "I am Mr. Brown, how are you?" becomes "i-am-mr-brown-how-are-you". Special characters like diacritics or umlauts are transliterated. The built-in character map can be overriden or extended by providing an associative array of custom mappings.

Also useful when creating anchor link names, for example for news entries in your custom EXT:news list template, in which case each news item's title would become an anchor:

And links would look much like the detail view links:

/news/#this-is-a-newsitem-title

When used with list views it has the added benefit of not breaking if the item referenced is removed, it can be read by Javascript (for example to dynamically expand the news item being referenced). The sanitized urls are also ideal to use for AJAX based detail views - and in almot all cases the sanitized string will be 100% identical to the one used by Realurl when translating using table lookups. /

  • Tag usage example

    <v:format.sanitizeString string="NULL" customMap="{foo: 'bar'}">
    	<!-- tag content - may be ignored! -->
    </v:format.sanitizeString>
  • Inline usage example

    {v:format.sanitizeString(string: 'NULL', customMap: {foo: 'bar'})}

Arguments

Argument Description Type
customMap

Associative array of additional characters to replace or use to override built-in mappings.

array
string

The string to sanitize.

string
Required attribute

Revision history

commit 69d00904e69cb2107d878b59e1812ec8b12aa588
Author: Björn Fromme <*****@bjo3rn.com>
Date:   Sun Dec 7 11:31:32 2014 +0100

    [TASK] Relocate viewhelper and add alias

commit 8bb2fc5ee124ba19b0a0ab8e061c9a153fc4651f
Author: Xaver Maierhofer <*****@xwissen.info>
Date:   Sun Jan 18 17:56:13 2015 +0100

    [TASK] Reference Copyright to license.md file