You are not logged in.
Pages: 1
Short of writing a plugin, does anyone have any ideas how to strip “http://” & a trailing slash from a URL?
For example a URL stored, say, in a custom field as “http://www.websitename.com/” would be output as “www.websitename.com”.
A plugin might do it as follows:
<txp:strip_http><txp:custom_field name=“link” /></txp:strip_http>
Thanks,
Adi
Offline
<txp:php>
echo preg_replace('#^(?:http://)?(.*?)/?$#', '$1', custom_field(array('name' => 'link')));
</txp:php>
or:
<txp:php>
echo rtrim(str_replace('http://', '', custom_field(array('name' => 'link'))), '/');
</txp:php>
Last edited by ruud (2008-08-23 13:37:35)
Offline
Pages: 1