Buy Now
Sign in

Load form in php file

armandocurcio , June 21 at 17:15
a
armandocurcio

Hi,
This question is already present in other posts * **
However, they were about version 5, but I'm asking about version 6 ;)
On a php file located in the 'view' folder of a Joomla module, I have to insert a form built with chronoformsv6.
Reading the old posts, I found this php code:

				JPluginHelper::importPlugin('content', 'chronoforms5');
$dispatcher =& JDispatcher::getInstance();
$form = $dispatcher->trigger('render_item', array('profile-information'))[0];
echo $form;


I believe that instead of 5 I have to put 6.
My question is: where do I have to insert the name of the form that I want to include?





* https://www.chronoengine.com/forums/posts/t99179/display-form-from-template-file.html?keywords=display%20form%20from%20template%20file
** https://www.chronoengine.com/forums/posts/t100292/load-form-in-php-file.html?keywords=display%20form%20from%20template%20file

admin

Hi Armand,

I did not write this code but try to replace "profile-information" with the form alias in your v6 ?

The cleanest solution is to run Joomla content plugins on the module and use the Chronoforms6 plugin syntax, and have the plugin installed and enabled of course.

Best regards,
Max

Max
If your main question got answered then please mark the answer using the button!

a
armandocurcio

Of course, but Chronoforms plugin does not work in php file :( (view/default.php)
so I try this code :)

admin

Hi Armand,

Please try this code then:

				
$mainframe = \JFactory::getApplication();

$contentParams = \JComponentHelper::getParams('com_content');
$dispatcher = \JDispatcher::getInstance();
$type = 'content';
\JPluginHelper::importPlugin($type);
$context = '';
$rowPlg = new \stdClass();
$rowPlg->text = '{chronoforms6}form-alias{/chronoforms6}';
$results = $mainframe->triggerEvent('onContentPrepare', array($context, &$rowPlg, &$contentParams, 0));
echo $rowPlg->text;


Best regards,
Max

Max
If your main question got answered then please mark the answer using the button!