Joomla模板管理器中的自定义HTML [英] Custom HTML in Joomla Template Manager
问题描述
在开发Joomla模板时,我陷入了这个问题。
While developing a Joomla Template, i got stuck on this qeustion.
每个Joomla模块都有一个清单。在该清单中,您可以使用Field和Fieldset类型为模板设置Paramaters。是否可以在这些部分中添加自定义图像?我尝试了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 文件中,找到参数所属的< fieldset>
,并在标记内添加以下内容:
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屋!