0

I am trying to make a plugin open a link in a new window, its the button that displays the certificate this is the plugin https://moodle.org/plugins/mod_customcert Tried asked on the forum but no answer from the developer. I believe i found the file (view.php) that does this but i dont understand where i should put a target=_blank (or maybe its another way). Here is the code i believe does that part:

 // Create the button to download the customcert.
$downloadbutton = '';
if ($canreceive) {
    $linkname = get_string('getcustomcert', 'customcert');
    $link = new moodle_url('/mod/customcert/view.php', array('id' => $cm->id, 'downloadown' => true));
    $downloadbutton = new single_button($link, $linkname, 'get', true);
    $downloadbutton->class .= ' m-b-1';  // Seems a bit hackish, ahem.
    $downloadbutton = $OUTPUT->render($downloadbutton);
}

Thanks in advance, its my first question here :)

1 Answers1

0

I think the 5th parameter for single button is html attributes, try

$downloadbutton = new \single_button($link, $linkname, 'get', true, ['target' => '_blank']);
Russell England
  • 9,436
  • 1
  • 27
  • 41