[英]How to add field or html in Joomla login form
I'm creating Joomla plugin in which I want to add iframe in login forms. 我正在创建Joomla插件,我想在其中添加登录表单中的iframe。 For that first I have created component to for adding custom field used it to add to xml in my plugin by using "onContentPrepareForm".
为此,我首先创建了要添加自定义字段的组件,并使用“ onContentPrepareForm”将其添加到插件中的xml中。 I want to know the best practice of doing that without change the core joomla files.
我想知道在不更改核心joomla文件的情况下的最佳做法。
myPlugin.php myPlugin.php
public function onContentPrepareForm($form, $data)
{
$app = JFactory::getApplication();
$option = $app->input->get('option');
switch($option) {
case 'com_users':
JForm::addFormPath(__DIR__ . '/forms');
$form->loadFile('iframe', false);
return true;
}
return true;
}
com_myfield com_myfield
class JFormFieldIframe extends JFormField {
protected $type = 'iframe';
// getLabel() left out
public function getInput() {
// generate and empty object
$plgParams = new JRegistry();
// get plugin details
$plugin = JPluginHelper::getPlugin('system','myPlugin');
// load params into our params object
if ($plugin && isset($plugin->params)) {
$plgParams->loadString($plugin->params);
}
$my_code = $plgParams->get('code','');
return '<iframe src="//yourdomain.com/abc.php?key='. $my_code
. '" id="'.$this->id.'" name="'.$this->name.'" />';
}
}
iframe.xml iframe.xml
<?xml version="1.0" encoding="UTF-8"?>
<form>
<fields name="iframe" >
<fieldset name="iframe" addfieldpath="/administrator/components/com_myfield/fields">
<field name="myiframe" type="iframe" default="" label="" description=""/>
</fieldset>
</fields>
</form>
Please reply as soon as possible I have deadline to meet. 请尽快答复我有截止日期。
Thanks! 谢谢!
Have you considered using a component template override? 您是否考虑过使用组件模板替代? It sounds like that's exactly what you're trying to do.
听起来这正是您要尝试执行的操作。
http://docs.joomla.org/How_to_override_the_output_from_the_Joomla!_core http://docs.joomla.org/How_to_override_the_output_from_the_Joomla!_core
Alternatively, you can use JDocument/getBuffer('component') to get the component's content, modify it, then setBuffer it back into JDoc. 另外,您可以使用JDocument / getBuffer('component')来获取组件的内容,对其进行修改,然后将其setBuffer返回JDoc。 api.joomla.org/cms-3/classes/JDocument.html I'd stick with template override though, it's a much cleaner solution.
api.joomla.org/cms-3/classes/JDocument.html尽管我坚持使用模板替代,但这是一个更干净的解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.