|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
bimal Smarty Elite
Joined: 19 Apr 2007 Posts: 423
|
Posted: Mon Feb 28, 2011 6:09 am Post subject: Prepend or remove "www." in a domain name |
|
|
Hello community,
This is a very simple demonstrative plugin that might be useful for you. It will prepend or remove the "www." portion from a domain name.
Code: | /**
* file: modifier.www.php
* Prepends or removes the 'www.' in a domain name.
* Helpful in shortening the name
*/
function smarty_modifier_www($domain_name='', $prepend=true)
{
if($prepend==false)
{
$domain_name = preg_replace('/^www\./is', '', $domain_name);
}
else
{
if(!preg_match('/^www\./is', $domain_name))
{
# Prepend www. if not available already
$domain_name = 'www.'.$domain_name;
}
}
return($domain_name);
} |
Usage examples:
{$domain_name|www:true} prepends www. if not available already.
{$domain_name|www:false} removes the www. from a domain name
Thank you. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|