简体   繁体   English

Joomla:获取在setState方法上修改的项目

[英]Joomla: get items modified on setState method

I have a component on two websites. 我在两个网站上都有一个组件。

When an user insert, update or delete an item in the first website, the same action must be performed on the second website. 当用户在第一个网站中插入,更新或删除项目时,必须在第二个网站上执行相同的操作。 I made that using the postSaveHook() method: when an action is performed in the first site, I connect to the database of the second site and replicate the action. 我使用postSaveHook()方法进行了此操作:在第一个站点中执行操作时,我连接到第二个站点的数据库并复制了该操作。

I need to do the same thing when an user changes the items' state: if he/she unpublishes two items, for example, the items must be unpublished in the second site. 当用户更改项目状态时,我需要做同样的事情:例如,如果他/她取消发布两个项目,则必须在第二个站点中取消发布这些项目。 I tried to change the setState() method to do that, but inside this method I couldn't get any referente to the items changed. 我试图更改setState()方法来执行此操作,但是在此方法中,我无法获得对更改项的任何引用。

Does anybody know another solution or how to do that with setState() ? 有谁知道另一种解决方案或如何使用setState()做到这一点?

PS Sorry about my English. PS对不起,我的英语。

Finally I found the solution: override the method public function publish(&$pks, $value = 1) of the class JModelAdmin . 最后,我找到了解决方案:重写类JModelAdmin的方法public function publish(&$pks, $value = 1) In this method I have all the primary keys of the items changed. 在这种方法中,我更改了项目的所有主键。 Then I was able to get their states and update the items on the second site. 然后,我能够获取它们的状态并更新第二个站点上的项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM