【发布时间】:2019-08-29 11:11:47
【问题描述】:
对于我的网站 (joomla),我需要一个表单,提交后将执行一些 PHP 代码。我在 joomla 扩展中没有找到任何表单组件,所以我尝试制作自己的组件。
我关注了this tutorial,但我被屏蔽了,因为我不明白如何显示和控制我的表单。
这是我的组件的结构
这里有一些我写的代码。 formff.xml
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.0" method="upgrade">
<name>Form FF!</name>
<!-- The following elements are optional and free of formatting constraints -->
<creationDate>Septembre 2019</creationDate>
<author>Rémi</author>
<authorEmail>contact@monsite.fr</authorEmail>
<authorUrl>www.monsite.fr</authorUrl>
<copyright>Copyright Info</copyright>
<license>License Info</license>
<!-- The version string is recorded in the components table -->
<version>0.0.1</version>
<!-- The description is optional and defaults to the name -->
<description>Description of the Form FF component ...</description>
<update> <!-- Runs on update; New since J2.5 -->
<schemas>
<schemapath type="mysql">sql/updates/mysql</schemapath>
</schemas>
</update>
<!-- Site Main File Copy Section -->
<!-- Note the folder attribute: This attribute describes the folder
to copy FROM in the package to install therefore files copied
in this section are copied from /site/ in the package -->
<files folder="site">
<filename>index.html</filename>
<filename>formff.php</filename>
<filename>controller.php</filename>
<folder>views</folder>
</files>
<administration>
<!-- Administration Menu Section -->
<menu link='index.php?option=com_formff'>Form FF!</menu>
<!-- Administration Main File Copy Section -->
<!-- Note the folder attribute: This attribute describes the folder
to copy FROM in the package to install therefore files copied
in this section are copied from /admin/ in the package -->
<files folder="admin">
<!-- Admin Main File Copy Section -->
<filename>index.html</filename>
<filename>formff.php</filename>
<!-- SQL files section -->
<folder>sql</folder>
</files>
</administration>
</extension>
admin 文件夹中没有特定代码,因为所有显示都是针对该站点的。所以我将只显示站点文件夹中的代码
formff.php
defined('_JEXEC') or die('Restricted access');
// Get an instance of the controller prefixed by FormFF
$controller = JControllerLegacy::getInstance('FormFF');
// Perform the Request task
$input = JFactory::getApplication()->input;
$controller->execute($input->getCmd('task'));
// Redirect if set by the controller
$controller->redirect();
controller.php
defined('_JEXEC') or die('Restricted access');
class FormFFController extends JControllerLegacy
{
}
view.html.php
defined('_JEXEC') or die('Restricted access');
class FormFFViewFormFF extends JViewLegacy
{
/**
* Display the From FF view
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return void
*/
function display($tpl = null)
{
// Assign data to the view
$this->msg = 'Formulaire';
// Display the view
parent::display($tpl);
}
}
default.php
defined('_JEXEC') or die('Restricted access');
?>
<h1><?php echo $this->msg; ?></h1>
default.xml
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout title="COM_FORMFF_FORMFF_VIEW_DEFAULT_TITLE">
<message>COM_FORMFF_FORMFF_VIEW_DEFAULT_DESC</message>
</layout>
</metadata>
我知道我可以通过使用这种 xml 文件来构建表单
default.xml
<?xml version="1.0" encoding="UTF-8"?>
<form>
<fields name="champs">
<fieldset name="ident">
<field
type="text"
name="clientnale"
id="clientnameff"
label="Name"
description="Enter your name"
size="80"
maxLength="255" />
</fieldset>
</fields>
</form>
但我真的不知道该怎么做才能显示和处理我的表单结果
有什么想法吗??
雷米
【问题讨论】:
-
请加入Joomla Stack Exchange,并请始终在此处发布所有 Joomla 问题。