I've recently upgraded my joomla site to 3.9.1, and now my custom components publish/unpublish buttons aren't working and I can't figure out why. The database column is called "state" and this is the code which was working up until the upgrade:

JToolbarHelper::publish('items.publish', 'JTOOLBAR_PUBLISH', true);
JToolbarHelper::unpublish('items.unpublish', 'JTOOLBAR_UNPUBLISH', true);

These buttons used to work and they would publish / unpublish the items, now I get this message:

0 items successfully published

I'm not sure where exactly the code is which tells it to update the status of the item, but for some reason it's not working anymore.

up vote 2 down vote accepted

Inside your table's constructor use setColumnAlias() to define the actual column name:

public function __construct($db)
{
    parent::__construct('#__example', 'id', $db);

    $this->setColumnAlias('published', 'state');
}
  • Thank you, I'm getting this error now: Error: 0 Call to undefined method EmploymentModelitems::setColumnAlias() – Leanne Seawright Dec 6 at 6:30
  • 1
    You seem to have added this to the model, not to the table class. Tables are typically found in administrator/components/com_example/tables directory. – Sharky Dec 6 at 6:32
  • lol I had indeed, thank you for your help, that worked!! – Leanne Seawright Dec 6 at 6:35

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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