Recent Topics

PluginSettingsEditDisplayBefore

Started by on Nov 13, 2013 – Contents updated: Nov 13, 2013

Nov 13, 2013 02:26    

I need a hook similar to PluginSettingsEditDisplayAfter but Before since i need to modify the Form output before it gets displayed.
Or do you know any other hooks that fires before displaying of the Form ? Or any other better way to customize Form output ? I've seen "layouts" but have no idea how to customize or create one.

Basically i need to redefine the whole Form interface, for example change <fieldset id...></fieldset> to <div id="mycustomids"></div> or wrap <input type="checkbox"..es with </div> for styling purposes.

I thought i could modify the html output via str_replace, preg_match etc etc. But if you know a better way to accomplish the above, i'd be glad to hear it.

Like being able to modify function form_checkbox( to do the above. I mean you get the idea.. You know i'm not the best when it comes to b2 core functions. I've made certain progress but couldnt get any results. Any advice is appreciated (preferrably with example :P ).

Nov 13, 2013 02:57

PHP

'whatever' => array(
    'layout' => 'html',
    'value' => '<div><em>My HTML code</em></div>',
),

Basically you can display your own form with 'layout' => 'html' or PluginSettingsEditDisplayAfter() and then catch input fields with PluginSettingsUpdateAction(). The only problem here is that you would need to handle your settings manually with $this->Settings->set() and $this->Settings->dbupdate()

You can also request the new event to be added in the next release

Nov 13, 2013 02:58

I believe I've done this in one of my plugins, can't remember which one was it.

Nov 13, 2013 03:01

See UserBlog, Avatars and Janrain plugins

Nov 13, 2013 12:33

Thanks, nice pointers. The problem is there is no DisplayProfileFormFieldset equivalent like DisplayPluginSettingsFormFieldset as in the avatars plugin.
It seems i need sth similar as in UserBlog plugin, RegisterFormSent & DisplayRegisterFormFieldset, but those only work for user forms of course.
I figured a way to display my custom Form i think. But i need a way to disable the default PluginSettings form display. I tried returning after PluginSettingsValidateSet or PluginSettingsEditAction but they dont seem to work for the moment being. I am still fiddling here and there, hopefully i can find a way out.

@sam2kb wrote earlier:

See UserBlog, Avatars and Janrain plugins

Nov 13, 2013 13:54

It turns out, there are absolutely no hooks available (that has the $Form available) before displaying of form PluginSettings.
At this point i must insist that we need a PluginSettingsEditDisplayBefore so that we can modify / disable the $Form before it gets displayed

The only candidate seems to be PluginSettingsEditAction but the $Form object cant be accessed with it.

Nov 13, 2013 16:53

in PluginSettingsEditDisplayAfter

PHP

$Form->output false;
// option 1: either display the form or drop it
// option 2: change form params (remove existing, add yours)

Nov 13, 2013 16:54

PluginSettingsEditDisplayAfter uses $Form by reference

Nov 13, 2013 17:21

Yeah that sounded promisin when i first saw that, i thought that was the solution. But it doesnt work the way i expect it, or am i doing something wrong ??

when i add

PHP

function PluginSettingsEditDisplayAfter( & $params ) {
        $params["Form"]->output false;

It displays the output for the following forms (pluginvariables, pluginevents), but not the PluginSettings form. How can i specify that i want to disable output for that, and that only ?

@sam2kb wrote earlier:

in PluginSettingsEditDisplayAfter

$Form->output = false;
// option 1: either display the form or drop it
// option 2: change form params (remove existing, add yours)

Nov 13, 2013 17:24

You only option is Javascript if you don't want to mess with ob_start() and ob_get_clean()

Nov 13, 2013 17:57

Well if i wanted a javascript solution, i wouldnt even have to go this far :D i'd simply use jQuery to manipulate the whole thing. I'd be happy if it worked without javascript, so i am willing to mess with it (:

@sam2kb wrote earlier:

You only option is Javascript if you don't want to mess with ob_start() and ob_get_clean()

Nov 13, 2013 17:58

Try ob_start() and ob_get_clean() and preg_replace() then

Nov 13, 2013 18:00

Thanks will give that a try..
OT: hit me up when you're available on skype
@sam2kb wrote earlier:

Try ob_start() and ob_get_clean() and preg_replace() then


Form is loading...

powered by b2evolution – This forum is powered by b2evolution CMS, a complete engine for your website.