Smarty如何解析模板文件中的URL

How would I translate this PHP statement: $domain = str_ireplace('www.', '', parse_url($url, PHP_URL_HOST)); to a smarty function such as:{$url|str_ireplace:'something':'etc'}

I want to print $domain in this case. $url is a smarty variable that is set for a certain URL. How do I do this?

You can pipe multiple modifiers, to first extract the host and then strip the www.:

{$url|parse_url:$smarty.const.PHP_URL_HOST|replace:'www.':''}

So for:

$url = 'http://www.example.com/foo/bar.html';

It prints:

example.com