⇦ Back to CoreButtonsTrait classMethod preview
public \Joomla\CMS\Toolbar\Button\PopupButton|\Joomla\CMS\Toolbar\Button\LinkButton
preview
(string $url, string $text = 'JGLOBAL_PREVIEW', mixed $newWindow = false)
Writes a preview button for a given option (opens a popup window).
Parameters
- string $url The name of the popup file (excluding the file extension)
- string $text The text of button.
- bool $newWindow Whether to open the preview in _blank or just a modal
Returns
- \Joomla\CMS\Toolbar\Button\PopupButton|\Joomla\CMS\Toolbar\Button\LinkButton
Since
Method preview - Source code
/**
* Writes a preview button for a given option (opens a popup window).
*
* @param string $url The name of the popup file (excluding the file extension)
* @param string $text The text of button.
* @param bool $newWindow Whether to open the preview in _blank or just a modal
*
* @return PopupButton|LinkButton
*
* @since 4.0.0
*/
public function preview(string $url, string $text = 'JGLOBAL_PREVIEW', $newWindow = false)
{
if ($newWindow === true) {
$button = $this->linkButton('link', $text)->url($url)->attributes(['target' => '_blank'])->icon('icon-eye');
} else {
$button = $this->popupButton('preview', $text)->url($url)->iframeWidth(640)->iframeHeight(480)->icon('icon-eye');
}
return $button;
}