Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Do I Add a Class to a CodeIgniter Anchor

I have the following:

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

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

class="top_parent"

This is so that when it's rendered in the browser, the code will look something like the following:

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

Thanks in advance, and any help is greatly appreciated.

--

Tom

like image 749
Tisch Avatar asked Apr 16 '09 00:04

Tisch


3 Answers

anchor('#', 'Home', array('class' => 'top_parent'));
like image 163
Mahtar Avatar answered Oct 17 '22 05:10

Mahtar


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.

like image 20
IEnumerator Avatar answered Oct 17 '22 04:10

IEnumerator


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

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

like image 3
Whitey Avatar answered Oct 17 '22 04:10

Whitey