CodeIgniter Forums
html_helper error in link_tag - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: html_helper error in link_tag (/showthread.php?tid=46382)



html_helper error in link_tag - El Forum - 10-29-2011

[eluser]Unknown[/eluser]
Hi, I found a bug html helper link_tag(). This is my solution

Code:
function link_tag($href = '', $rel = 'stylesheet', $type = 'text/css', $title = '', $media = '', $index_page = FALSE)
{
  $CI =& get_instance();

  $link = '<link ';

  if (is_array($href))
  {
   foreach ($href as $k=>$v)
   {
    if ($k == 'href' AND strpos($v, '://') === FALSE)
    {
     if (isset($href['index_page']) && $href['index_page'] === TRUE)
     {
      $link .= 'href="'.$CI->config->site_url($v).'" ';
     }
     else
     {
      $link .= 'href="'.$CI->config->slash_item('base_url').$v.'" ';
     }
    }
    else
    {
     $link .= "$k=\"$v\" ";
    }
   }

   $link .= "/>";
  }