Hook for children-parent

Wish to see a specific feature/change in future releases? Feel free to post it here, and if it gets enough "likes", we'd definitely include it in future releases!
Post Reply
User avatar
landinialejandro
AppGini Super Hero
AppGini Super Hero
Posts: 126
Joined: 2016-03-06 00:59
Location: Argentina
Contact:

Hook for children-parent

Post by landinialejandro » 2017-10-28 23:46

Hi!
I was looking for a way to modify the children table without having to rewrite the code each time the application is compiled.
and I came up with the idea of ​​implementing a Hook in the "parent-children.php" file.
I put the following code: (just before / * process requested operation * /)

Code: Select all

if ($ChildTable) {
            $function_name = $ChildTable. '_init_child';
            @include ("$currDir/hooks/$ChildTable.php");
            if (function_exists ($function_name)) {{
                            $args = array ();
                            $render = $ function_name ($userPCConfig [$ChildTable], getMemberInfo (), $args);
                    }
        }
and now I put the function "tablename_ini_child" inside "tablename.php" inside the hook folder and I can modify some parameters before visualizing the children table.
This would allow to keep a lot of code without needing to rewrite it (or re-paste it).

In my case, for example, I change the number of 'records-per-page' and the 'tenplate':

Code: Select all

function DetailsComprobantes_init_child (& $ options, $ memberInfo, & $ args) {
                
                foreach ($options as $x => $a) {
                    $options[$x]['template'] = 'children-DetailsComprobantes_new';
                    $options[$x]['records-per-page'] = '3';
                }
                
return TRUE;
}
in $ options, comes the array of values, the rest is equal to the normal function tablename_init of the hook.
I hope it serves.
Any doubt I remain available.
Alejandro.
AppGini 5.98 - Linux OpenSuse Tumblewweed.

Some of my posts that may interest you:
:arrow: Landini Admin Template: Template for Appgini like AdminLTE
:arrow: Profile image plugin: add and changue image user profile
:arrow: Field editor in table view: Configurable fast edit fields in TV
:idea: my personal page

Post Reply