I would like to extend the (un)publish-function in a sub controller.

I thought it would be enough to write something like that to my sub controller items.php:

    public function unpublish()
        echo "Test";

But on unpublishing my items nothing happens. What can I do here?

  • Have any feedback?
    – Rene Korss
    Commented Jul 14, 2015 at 12:43
  • Sorry, I forgot to mark this as "solved". Your solution works great :-)
    – MyFault
    Commented Jul 14, 2015 at 12:54
  • Maybe you can help me with an affiliated topic: joomla.stackexchange.com/questions/10814/… Again: Thank you very much for your great support!
    – MyFault
    Commented Jul 14, 2015 at 12:59

1 Answer 1


Take a look at JControllerAdmin what is used to extend your controller.

In __construct function on line 62 unpublish is set to use publish function. So there is no function like unpublish.

And in publish function you can get task name with $task = $this->getTask();.

Possible values are publish, unpublish, archive, trash and report. So you can compare, if it is publish or unpublish and make actions based on that.

Your function could look like this:

public function publish()
    $task = $this->getTask();

    // Do your custom actions
    if($task == 'unpublish'){
        // Do something on unpublishing item(s)
    }else if($task == 'publish'){
        // Do something on publishing item(s)

    // Call parent function, so item(s) will get published/unpublished like they are used to

Your Answer

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

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