【发布时间】:2013-09-02 15:38:54
【问题描述】:
我想创建一个前端 joomla 组件,这是我的第一次体验。
这里有重要的事情:
1-component/controller.php
class TestController extends JControllerLegacy
{
public function display($cachable = false, $urlparams = false)
{
$view= JFactory::getApplication()->input->getCmd('view','items');
JFactory::getApplication()->input->set('view', $view);
parent::display($cachable, $urlparams);
}
}
2:com_test/model/items.php
<?php
defined('_JEXEC') or die();
jimport( 'joomla.application.component.modellist' );
class TestModelItems extends JModelList
{
public function __construct($config = array())
{
if (empty($config['filter_fields']))
$config['filter_fields'] = array('id', 'title', 'catid');
parent::__construct($config);
}
function getListQuery()
{
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select(...)
return $query;
}
}
我可以在视图文件夹的default.php上打印查询结果! 但我想要另一件事。
我的网站首页的自定义模块中有这样的表单:
<form action="" method="post">
<input type="text" name="wordsearch" value="search">
.
.
<input type="submit" />
</form>
现在!
我不知道如何将这个表单(使用 post 方法)发送到模型文件夹中的 getListQuery() 函数...怎么做?
我想当某人点击提交表单时,组件根据表单的值过滤查询sql,然后向用户显示新的结果!
我用谷歌搜索了几个小时,但没有机会解决。感谢您的帮助。
【问题讨论】:
标签: forms joomla components jinput