Problems, need help? Have a tip or advice? Post it here.
5 posts Page 1 of 1
I've been working on customizing the repeatable plugin, the render actually. The problem is that in order to do so I need to modify the original file but I'd like to keep everything modular so that I can reduce direct changes to the core code.

Do you know if there's a way to do it?
Perhaps, you can register your own renderable, it will have priority over default one.
trendoman wrote: Perhaps, you can register your own renderable, it will have priority over default one.


The thing is that the repeatable plugin is rendered using the _render function from KUserDefinedField instead of registering a render like other fields.
@brunosa, you are right; unlike most other editable regions, RR does not lend its render routine to overriding.
Also, the fact that <cms:repeatable> tag internally calls a a hidden editable region named '__repeatable' also complicates things a little.

That said, there are always way to get around things. Please try the following -
Place the following code in your 'addons/kfunctions.php' file:
Code: Select all
$FUNCS->add_event_listener( 'init', function(){
    global $FUNCS;

    $FUNCS->udfs['__repeatable']['handler']='MyRepeatable';
});
class MyRepeatable extends Repeatable{
    function _render( $input_name, $input_id, $extra='', $dynamic_insertion=0 ){
        global $FUNCS, $CTX, $AUTH;

        $html = parent::_render( $input_name, $input_id, $extra='', $dynamic_insertion );

        return $html;
    }
}

As you can see, we have defined our own class 'MyRepeatable' that extends the core 'Repeatable' class.
We are only interested in the _render() function - in the code above the function is simply calling the original core routine of its parent so should work exactly the same as before. You can instead, now copy/paste here the original code and tweak it to your liking.

This will keep all your changes isolated to your own class without needing to modify any core file.

Hope this helps.
Holy moly KK, that's amazing!

What does $FUNCS->udfs do? Does it holds all the editables field types?
5 posts Page 1 of 1
cron