2

I would like to create a little dialog on publishing-events on an item of my self-developed component.

For example: Item gets published - the item's controller is called and rund method publish with $task publish.

But now I would like to interrupt publishing-process: The user shall answer a question - for example:

Are you sure? Yes (publish) or No (exit)

This is the source of my controller so far:

/**
 * publish function.
 * 
 * @access public
 * @return void
 */
public function publish()
{
    $app                                    =   JFactory::getApplication();
    $jinput                                 =   JFactory::getApplication()->input;
    $ids                                    =   $jinput->get('cid', '', 'array');
    $task                                   =   $this->getTask();
    $date                                   =   JFactory::getDate();            
    $modelitem                              =   $this->getModel('Item');        

    foreach($ids as $id)
    {           
        switch($task)
        {
            case 'publish'  :                   // do stuff
                                                break;
            case 'unpublish':                   // do stuff
                                                break;
            case 'archive'  :                   // do stuff     
                                                break;
            case 'trash'    :                   // do stuff                                                 
                                                break;
        }

    }

    $publish                                =   $modelitem->publish($id, $state);

    $this->setRedirect('index.php?option=com_bestia&view=items', false);

    return true;
}   

1 Answer 1

1

The simplest way to implement a Confirmation dialog is on the client side, with Javascript routine. You can check how JToolbar does it:

    $bar = JToolbar::getInstance('toolbar');

    // Add a trash button.
    $bar->appendButton('Confirm', JText::_('COM_XXX_CONFIRM_PURGE'), 'trash', $alt, $task, $check, false);

In Javascript terms:

    if (confirm('....')){Joomla.submitbutton('....');}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.