Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Prepend or remove "www." in a domain name

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
bimal
Smarty Elite


Joined: 19 Apr 2007
Posts: 423

PostPosted: Mon Feb 28, 2011 6:09 am    Post subject: Prepend or remove "www." in a domain name Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP