Custom HTML in Joomla Template Manager

落爺英雄遲暮 提交于 2019-12-11 06:57:32

问题


While developing a Joomla Template, i got stuck on this question.

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.


回答1:


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".

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="" />

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



来源:https://stackoverflow.com/questions/20350220/custom-html-in-joomla-template-manager

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!