Joomla:将表单字段从模块发布到组件

发布于 2024-12-01 12:45:42 字数 275 浏览 0 评论 0原文

我是 Joomla 开发的初学者。我开发了一个评级模块,如下所示。

在此处输入图像描述

我已设法从数据库中获取评分,但我不知道如何插入数据库当用户单击投票按钮时。

我的模块中有一个表单,其中包含四个下拉框和一个提交按钮(投票)。现在我计划开发一个组件来处理这个表单数据。我应该如何开发我的组件来处理这个问题?我的模块中的表单操作应该是什么?

任何帮助表示赞赏。提前致谢。

I am a beginner to Joomla development. I have developed a rating module which looks as below.

enter image description here

I have managed to get the ratings from my database, but I do not know how to insert into the database when user clicks the vote button.

I have a form in my module which contains the four drop down boxes and a submit button (Vote). Now I am planning to develop a component in order to process this form data. How should I develop my component to process this? And what should be the form action in my module?

Any help is appreciated. Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

提笔落墨 2024-12-08 12:45:42

创建组件
http://docs.joomla.org/Developing_a_Model-View-Controller_Component__-_Part_1
创建模块
http://docs.joomla.org/Creating_a_simple_module

您必须使用 JRoute 指定模块的操作
http://docs.joomla.org/Supporting_SEF_URLs_in_your_component

查看组件代码示例

$controller->execute( JRequest::getWord( 'task' ) );

,因此您必须创建控制器和特殊组件处理数据的任务方法

如果您根本不需要组件,您可以将逻辑放入模块中
通过这种方式,模块应该对当前页面有表单操作并处理类似的逻辑

$elements = JRequest::getVar('vote_data', array(), 'post');
if(count($elements)) {
   // do something
}

Create component
http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_1
Create module
http://docs.joomla.org/Creating_a_simple_module

you must specify action of your module with JRoute
http://docs.joomla.org/Supporting_SEF_URLs_in_your_component

look at component code example

$controller->execute( JRequest::getWord( 'task' ) );

so you must create controller and special task method for processing data

If you don't need component at all you can put logic in your module
In this way module should have form action to current page and process logic something like

$elements = JRequest::getVar('vote_data', array(), 'post');
if(count($elements)) {
   // do something
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文