Friday, April 29, 2011

how do I add a class to a CodeIgnitor anchor?

I have the following:

'.anchor('','Home').'

and I want to add the following CSS class to it:

class="top_parent"

so that when its rendered in the browser, the code will look something like

<a href="#" class="top_parent">Home</a>

Thanks in advance. Any help is hugely appreciated.

Tom

From stackoverflow
  • You can specify an associative array of attributes for your Anchor. So, for example:

    anchor('', 'Home', array('class' => 'top_parent'));

  • anchor('#', 'Home', array('class' => 'top_parent'));
    
  • The Codeignitor function is defined as such:

    function anchor($uri = '', $title = '', $attributes = '')
    

    I would try sending an array with a class key and value first.

    These functions are found inside the \system\helpers\ folder.

    NTulip : boy all that time i spend finding the function and two very talented people had answered the question already. Oh well - my answer is here to stay.

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.