OK, in case anyone else has this problem, here's how I solved it ...
This code goes in .../administrator/views/xxx/view.html.php:
This code goes in .../administrator/views/xxx/view.html.php:
Code:
public function display($tpl = null) { $this->item = $this->get('Item'); // Check for errors. if (count($errors = $this->get('Errors'))) throw new Exception(implode("\n", $errors), 500); $this->addToolbar(); parent::display($tpl); } protected function addToolbar() { JToolBarHelper::custom('dummyTask', 'arrow-left', 'arrow-left', 'Back', false); $doc = JFactory::getDocument(); $doc->addScriptDeclaration(" document.addEventListener('DOMContentLoaded', function() { var button = document.querySelector('#toolbar-arrow-left'); if (button) { if (window.history.length === 1) { button.setAttribute('disabled', 'disabled'); button.setAttribute('aria-disabled', 'true'); button.classList.add('disabled'); button.style.pointerEvents = 'none'; } else { button.addEventListener('click', function(event) { event.preventDefault(); window.history.back(); }); } } }); "); if (JFactory::getUser()->authorise('core.admin', 'com_component_name')) JToolBarHelper::preferences('com_component_name'); else JFactory::getApplication()->input->set('hidemainmenu', true); JToolBarHelper::title(JText::_($this->item->title, 'help')); }
Statistics: Posted by david0058 — Tue Oct 15, 2024 11:13 am