php - How to add field or html in Joomla login form -
i'm creating joomla plugin in want add iframe in login forms. first have created component adding custom field used add xml in plugin using "oncontentprepareform". want know best practice of doing without change core joomla files.
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
class jformfieldiframe extends jformfield { protected $type = 'iframe'; // getlabel() left out public function getinput() { // generate , empty object $plgparams = new jregistry(); // plugin details $plugin = jpluginhelper::getplugin('system','myplugin'); // load params 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
<?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 possible have deadline meet.
thanks!
have considered using component template override? sounds that's you're trying do.
http://docs.joomla.org/how_to_override_the_output_from_the_joomla!_core
alternatively, can use jdocument/getbuffer('component') component's content, modify it, setbuffer jdoc. api.joomla.org/cms-3/classes/jdocument.html i'd stick template override though, it's cleaner solution.
Comments
Post a Comment