3

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.

  • Guys after upgrading to joomla 3.9 i faced the same problem as above. I am now facing a similar problem with creating a new file, it saves the record but the id returned is 0 – maurice Jan 23 at 7:13
  • 1
    @Leanne In case you are unaware, you can ask the Stack Exchange administrators to merge your two accounts. I've not personally done this, but it is possible. stackoverflow.com/users/92129/souliebaby advice: meta.stackexchange.com/q/18232/352329 – mickmackusa Feb 23 at 6:08
3

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 '18 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 '18 at 6:32
  • lol I had indeed, thank you for your help, that worked!! – Leanne Seawright Dec 6 '18 at 6:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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