I just want to know how can I add a _blank target type to a link if a link is pointing to an external domain (_self for internals). I was doing this by checking the url but it was really hard coded and not reusable for other sites.
Do you have any idea of how to do it properly with PHP ?
$target_type=(strpos($ref, $_SERVER['HTTP_HOST'])>-1
|| strpos($ref,'/')===0? '_self' : '_blank');
if ($ref<>'#' && substr($ref,0,4)<>'http') $ref='http://'.$ref;
$array['href']=$ref;
if (substr($ref,0,1)<>'#') $array['target']= $target_type;
$array['rel']='nofollow';
if (empty($array['text'])) $array['text']=str_replace('http://','',$ref);
This is only working for the main domain, but when using domain.com/friendlyurl/, is not working.
Thanks in advance
NOTE : Links can contain whether http:// protocol or not and they use to be absolute links. Links are added by users in the system