Back to Toolbar class

Method render

public string
render
(array $options = [])
Render a toolbar.
Parameters
  • array $options The options of toolbar.
Returns
  • string HTML for the toolbar.
Since
  • 1.5
-
  • \Exception
Class: Toolbar
Project: Joomla

Method render - Source code

/**
 * Render a toolbar.
 *
 * @param   array  $options  The options of toolbar.
 *
 * @return  string  HTML for the toolbar.
 *
 * @throws \Exception
 * @since   1.5
 */
public function render(array $options = [])
{
    $html = [];
    $isChild = !empty($options['is_child']);
    // Start toolbar div.
    if (!$isChild) {
        $layout = new FileLayout('joomla.toolbar.containeropen');
        $html[] = $layout->render(['id' => $this->_name]);
    }
    $len = count($this->_bar);
    // Render each button in the toolbar.
    foreach ($this->_bar as $i => $button) {
        if ($button instanceof ToolbarButton) {
            // Child dropdown only support new syntax
            $button->setOption('is_child', $isChild);
            $button->setOption('is_first_child', $i === 0);
            $button->setOption('is_last_child', $i === $len - 1);
            $html[] = $button->render();
        } else {
            $html[] = $this->renderButton($button);
        }
    }
    // End toolbar div.
    if (!$isChild) {
        $layout = new FileLayout('joomla.toolbar.containerclose');
        $html[] = $layout->render([]);
    }
    return implode('', $html);
}