- users are allowed to enter URL's in a text input box.
- That URL has to be used later on to create a href
- If the user didn't enter "http://", the href will be send visitors to "http://www.yourwebsite.com/www.someotherwebsite.com" instead of "http://someotherwebsite.com" (may be only the case if you use pretty URL's, didn't test...)
Solution:
Use http://stackoverflow.com/a/8591679/1338546 in a UDT
In the template:
Code: Select all
<a href="{checkurl url="{$oneuser.properties.website}"}">...</a>
Code: Select all
$urlStr = $params['url'];
$parsed = parse_url($urlStr);
if (empty($parsed['scheme'])) {
$urlStr = 'http://' . ltrim($urlStr, '/');
};
echo $urlStr;