sumanta ghosh sumanta ghosh - 5 months ago 25
PHP Question

convert Moodle php single_button to a link

I need to change the following code to replace the button with a clickable link
something like

Course >

Basically I would still use the resulting link but instead of a button, I need it to be a link button. So that user can middle click and open it in a different tab if needed.

if (has_capability('block/progress:overview', $this->context)) {
$parameters = array('progressbarid' => $this->instance->id, 'courseid' => $COURSE->id);
$url = new moodle_url('/blocks/progress/overview.php', $parameters);
$label = get_string('overview', 'block_progress');
$options = array('class' => 'overviewButton');
$this->content->text .= $OUTPUT->single_button($url, $label, 'post', $options);
}


Its the single_button element that I need to change.
Please help.

Answer

Replace this

$this->content->text .= $OUTPUT->single_button($url, $label, 'post', $options);

With this

$this->content->text .= html_writer::link($url, $label);
Comments