adding a class to html_writer::link

adding a class to html_writer::link

by dan k -
Number of replies: 3

hey guys,

this is being the worst headache i've had with moodle lately,

the html_writer there is no documentation what so ever for this thing.

I need to add a class to a link:

 html_writer::link(new moodle_url('/grade/report/user/index.php', array('id' => $course->id, 'userid' => $this->user->id)), $courseshortname);

but i can't find it anywhere how to do that.... 

can someone help?

cheers!

dan

Average of ratings: -
In reply to dan k

Re: adding a class to html_writer::link

by David Monllaó -

Hi dan,

class is an attribute like any other tag attr, try with

html_writer::link(new moodle_url('/grade/report/user/index.php', array('id' => $course->id, 'userid' => $this->user->id)), $courseshortname, array('class' => 'YOUR-CLASS'));

In reply to David Monllaó

Re: adding a class to html_writer::link

by dan k -

sweet that works i was adding that array before $courseshortname and it was braking the code.

thanks!

this doesn't work:

$courselink = html_writer::link(new moodle_url('/grade/report/user/index.php', array('id' => $course->id, 'userid' => $this->user->id)),  array('class' => 'YOUR-CLASS'), $courseshortname);


Average of ratings: Useful (1)