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, 2019 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, 2019 at 6:08

2 Answers 2


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() Dec 6, 2018 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, 2018 at 6:32
  • lol I had indeed, thank you for your help, that worked!! Dec 6, 2018 at 6:35

I faced the same problem. Only for me, the unpublish worked, and the publish did not. Solved by deleting rows from the table file.

if ( empty( $array['published'] ) ){
    $array['published'] = '1';
  • While this may have worked for your project, I am wary about suggesting that researchers manually overwrite the published value if it is "not set or zero/falsey". I mean, if $array['published'] = 0 or $array['state'] = 0, then your script will always declare $array['published'] = 1 -- this kind of defeats the purpose of the toggleable value. Comparing this advice to Sharky's, I'd say it is a bad idea to ignore the database data coming from published/state.
    – mickmackusa
    Feb 14, 2021 at 22:56
  • If $array['published'] is empty, the default value is provided in the database. I repeat that this if ( empty( $array['published'] ) ){ $array['published'] = '1';} gives a bug when working with JHtml::_( 'jgrid.published', $item->state, $i, 'tickets.', $canChange, 'cb' ); Just as the error of the buttons on the toolbar
    – MaXX
    Feb 16, 2021 at 12:28

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.