urlize modifier
1Presentation
This Smarty modifier transforms a string so that it can be used in a URL. It uses the urlize() method of the \Temma\Utils\Text object.
2Usage
Here is an example:
<ul>
{foreach $articles as $article}
<li>
<a href="/article/show/{$article.id}/{$article.title|urlize}">
{$article.title}
</a>
</li>
{/foreach}
</ul>
- Lines 2 to 8: A loop goes through all the items stored in the $articles list.
- Line 4: A link to each article is created. The URL contains the article identifier and its title after "URLification".
- Line 5: The title of each article is displayed as a link.
3Examples
{'Hello world'|urlize} {* 'hello-world' *}
{'àéïöùÿ'|urlize} {* 'aeiouy' *}
{'Questions?? Answers!!'|urlize} {* 'questions-answers' *}