Joomla 模板管理器中的自定义 HTML [英] Custom HTML in Joomla Template Manager
问题描述
在开发 Joomla 模板时,我被这个问题困住了.
While developing a Joomla Template, i got stuck on this question.
每个Joomla 模块都有一个清单.在该清单中,您可以使用 Field 和 Fieldset 类型为模板设置参数.是否可以在这些部分添加自定义图像?我为此尝试了 CDATA
但它不起作用.
Every Joomla Module has a manifest. In that manifest you can set your Paramaters for your template with Field and Fieldset types. Is it possible to add a custom image in these sections? I tried CDATA
for this but it doesn't work.
推荐答案
我从来没有用模板尝试过这个,只有插件和模块,但我相信它仍然是相同的概念.
I've never tried this with a template, only a plugin and module, but I believe it's still the same concept.
在您的模板文件夹中创建一个新文件夹并将其命名为元素".
Create a new folder in your template folder and name it "elements".
然后,在您的 template.xml 文件中,找到该参数所属的 并在标签内添加以下内容:
Then, in your template.xml file, find the <fieldset>
that the parameter belongs to and add the following inside the tag:
addfieldpath="/modules/mod_social_slider/fields"
您现在需要像这样添加一个新的参数字段:
You now need to add a new parameter field like so:
<field name="image" type="custom" default="" label="" description="" />
现在,创建一个新的 PHP 并将其放在新创建的元素"文件夹中,并将其命名为custom.php".然后添加以下代码:
Now, create a new PHP and place it inside your newly created "elements" folder and call it "custom.php". Then add the following code:
<?php
defined('_JEXEC') or die('Restricted access');
class JFormFieldCustom extends JFormField {
protected $type = 'Custom';
protected function getInput() {
return '<img src="' . JUri::root() . 'templates/your_template/images/image.jpg" alt="" />';
}
}
?>
请注意,我尚未对此进行测试,因此请告诉我它是否有效
Note that I haven't tested this so let me know if it works or not
这篇关于Joomla 模板管理器中的自定义 HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!