问题描述
我查看了 administratorcomponentscom_k2 文件夹中的所有位置,但找不到在 K2 中保存新项目文章的代码.我检查了模型文件夹下的 item.php 文件.没有运气.
I have looked every where in the administratorcomponentscom_k2 folder but am not able to find the code that saves a new itemarticle 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 行:函数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 中保存新项目的标题和别名的代码在哪里的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!