• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

Load plugin from form submittion passing form field as parameter (Plugin with dynamic param)

urbanasur

New Member
Hi. I want to load a plugin from form submittion passing a form field as parameter. To do this I try using de php plugin and put in the php code:

$content = JHTML::_("content.prepare", "{pluginname}param1=paramvalue{/pluginname}");
echo $content;

If I select Process Script option "before the form is loaded (onLoad)", the plugin loads, but if I select Process Script option "EndofFormSubmission (onAfterProcess)", the plugin doesn't load.

I want to know what is wrong and how to pass paramvalue from a form field. The idea is to load a plugin dynamically with parameters selected by user.

Thanks.
 
Well onAfterProcess isn't going to work, because that happens during form submission, not during form load. So nothing you do in submission is going to be visible, either when the form is being loaded for display (because the 'process' hooks don't run during load), or after the form has finished submitting, because we always redirect to another page after submitting.

It might help if you explained in more detail what you are actually trying to achieve.

-- hugh
 
Hi Hugh. Thanks for your answer.
I want the user enter a value (for example number 30) in a text field of a form, and that value (number 30) be the parameter of a plugin (for example {pluginname}param1=30{/pluginname}"). How can I do it?
Thanks.
 
But where / when do you want to render that plugin? In a form view, or a detail view or a list view, or in an unrelated J! article?

What is the work flow?

-- hugh
 
I try to do it in a form view, but if is in an unrelated joomla article its ok too.
Form with text field --> Load another form with the plugin loaded (like search form in joomla)
Thanks.
 
Have you tried using the "Process Joomla plugins" setting in the "Options" for your form? When that is enabled we run the final output of your form through J!'s plugin processing.

You could then use a calc element, like ...

PHP:
return "{pluginname}param=" . '{tablename___yourelement'} . "{/pluginname}";

I think this will work, although there's a chance we might mistake the {pluginname} for a Fabik placeholder, and remove it.

-- hugh
 
Hi Hugh. Thanks for your help.

I set the "Process Joomla plugins" setting in the "Options" in the form to "Detail & form view". Then I download and installed the element calc plug-in.
Configure two elements in the form: a field element text box (parameter) called "SearchPhoto" and the calc element. And then set in calculation of the calc element:
return"{pluginname}param=" . {___SearchPhoto} . "{/pluginname}";
and "Ajax Calcultation" option set to Yes.

When de form load the first time the plugin loads ok!, but when the SearchPhoto text box change, for example set value 22, only show the syntax text:
{pluginname}param=22{/pluginname}
The param value is ok, and the syntax is ok, but not load the plugin.

If a replace the param with a value and put it in the calculation:
return"{pluginname}param=22{/pluginname}";
I have the same result, loads the first time and then show the syntax text.

Any idea?
Thanks again.
 
Yeah, AJAX won't work for that, as the plugin processing is done in the form view display, not in the calc element processing.

If you need it to work for AJAX calls you'll need to run the J! plugin processing yourself in the calc. We have a helper function to do that, FabrikHelperHTML::runContentPlugins($text)

Hugh


Sent from my HTC One using Tapatalk
 
Hi Hugh.
Yes I need o work the J! plugin processing in the calc using Ajax like you told me, but using the function FabrikHelperHTML don't load the plugin.

I used this syntax in the calculation field of calc element:

$text = "{pluginname}param=" . {___SearchPhoto} . "{/pluginname}"; //dynamic value
or
$text = "{pluginname}param=22{/pluginname}"; //fixed value

FabrikHelperHTML::runContentPlugins($text);

Is there something wrong? I tried to search samples of this functions in forums but I didn?t find it.

Thanks again.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top