Joomla-K2中保存新项目的标题和别名的代码在哪里 [英] Joomla - Where is the code in K2 which saves a new item's Title and alias
问题描述
我已经查看了administrator \ components \ com_k2文件夹中的每个位置,但是找不到在K2中保存新项目\ article的代码.我检查了models文件夹下的item.php文件.没有运气.
I have looked every where in the administrator\components\com_k2 folder but am not able to find the code that saves a new item\article in K2. I checked the item.php file under models folder. No luck.
我需要重写K2项目保存方法.
I need to override the K2 item save method.
我需要知道将项目标题和别名保存到#__ K2_content表中的确切方法.
I need a know the exact method that saves the Item's title and alias into the #__K2_content table.
我必须在保存的joomla文章中复制K2项,并在垃圾箱/删除项中将其删除.
I have to duplicate the K2 items in joomla articles on save and remove on trash/delete.
我已经成功地能够覆盖K2核心代码.但是无法找到正确的代码来覆盖. (替代方法是此处)
I have successfully been able to override the K2 core code. But am unable to find the right code to override. (override method is here)
推荐答案
存储K2项(至少在最新的K2版本-2.6.5中)的表为#__k2_items
,而不是#__ k2_content.
The table that stores the K2 items (at least in the latest K2 version - 2.6.5) is #__k2_items
, not #__k2_content.
我遍历了代码,看起来K2使用了Joomla的方法:请参阅administrator/components/com_k2/controllers/item.php-第24行:function save().一切都从Joomla类扩展了.
I went through the code, it looks like K2 uses Joomla's methods: see administrator/components/com_k2/controllers/item.php - line 24: function save(). Everything is extended from Joomla classes.
class K2ControllerItem extends K2Controller
{
public function display($cachable = false, $urlparams = array())
{
JRequest::setVar('view', 'item');
parent::display();
}
function save()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('item');
$model->save();
}
.....
}
K2控制器:/administrator/components/com_k2/controllers/controller.php
The K2 controller: /administrator/components/com_k2/controllers/controller.php
...
else if (version_compare(JVERSION, '2.5', 'ge'))
{
class K2Controller extends JController
{
public function display($cachable = false, $urlparams = false)
{
parent::display($cachable, $urlparams);
}
}
}
...
这篇关于Joomla-K2中保存新项目的标题和别名的代码在哪里的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!