Back to ToolbarHelper class

Method versions

public static void
versions
(mixed $typeAlias, mixed $itemId, mixed $height = 800, mixed $width = 500, mixed $alt = 'JTOOLBAR_VERSIONS')
Writes a version history
Parameters
  • string $typeAlias The component and type, for example 'com_content.article'
  • int $itemId The id of the item, for example the article id.
  • int $height The height of the popup.
  • int $width The width of the popup.
  • string $alt The name of the button.
Returns
  • void
Since
  • 3.2
Class: ToolbarHelper
Project: Joomla

Method versions - Source code

/**
 * Writes a version history
 *
 * @param   string   $typeAlias  The component and type, for example 'com_content.article'
 * @param   integer  $itemId     The id of the item, for example the article id.
 * @param   integer  $height     The height of the popup.
 * @param   integer  $width      The width of the popup.
 * @param   string   $alt        The name of the button.
 *
 * @return  void
 *
 * @since   3.2
 */
public static function versions($typeAlias, $itemId, $height = 800, $width = 500, $alt = 'JTOOLBAR_VERSIONS')
{
    $lang = Factory::getLanguage();
    $lang->load('com_contenthistory', JPATH_ADMINISTRATOR, $lang->getTag(), true);
    /** @var \Joomla\CMS\Table\ContentType $contentTypeTable */
    $contentTypeTable = Table::getInstance('Contenttype');
    $typeId = $contentTypeTable->getTypeId($typeAlias);
    // Options array for Layout
    $options = array();
    $options['title'] = Text::_($alt);
    $options['height'] = $height;
    $options['width'] = $width;
    $options['itemId'] = $typeAlias . '.' . $itemId;
    $bar = Toolbar::getInstance('toolbar');
    $layout = new FileLayout('joomla.toolbar.versions');
    $bar->appendButton('Custom', $layout->render($options), 'versions');
}