• 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.

Fabrik Custom template Help

Hope someone with more experience than me can help this amateur.

I am trying to create a custom template.

I have a form with several tabs on it.

On one of these tabs there are 24 elements.

For the 5th,10th,15th and 20th element I want to change the table heading to span 4 elements. Then I can hide the others in CSS.

If I change this in a copied default_repeat_group_table.php

Code:
// Add in the table heading
    $firstGroup = $group->subgroups[0];
    foreach ($firstGroup as $el) :
        $style = $el->hidden ? 'style="display:none"' : '';
        ?>
        <th <?php echo $style; ?> class="<?php echo $el->containerClass?>">
            <?php echo $el->label_raw?>
        </th>
        <?php
    endforeach;

To this

Code:
// Add in the table heading
    $firstGroup = $group->subgroups[0];
    foreach ($firstGroup as $el) :
        $style = $el->hidden ? 'style="display:none"' : '';
        ?>
        <th colspan= "4" <?php echo $style; ?> class="<?php echo $el->containerClass?>">
            <?php echo $el->label_raw?>
        </th>
        <?php
    endforeach;

It changes all my headings to span 4 as you would expect.

I assume that I need to test for the group and then test for the element with IF , but if I'm honest I don't really have a great grasp of PHP.
I could write an IF to select a variable of 4 or 1 depending on element and group, but I don't understand how to use that result?

I referred to this

Thank you Rob great video.
 
This is how I achieved this, it may not be the most elegant approach!

In a copy of default_repeatgroup_table.php I replaced this

Code:
    // Add in the table heading
    $firstGroup = $group->subgroups[0];
    foreach ($firstGroup as $el) :
        $style = $el->hidden ? 'style="display:none"' : '';
        ?>
        <th <?php echo $style; ?> class="<?php echo $el->containerClass?>">
            <?php echo $el->label_raw?>
        </th>
        <?php
    endforeach;

with this

Code:
// Add in the table heading
    $firstGroup = $group->subgroups[0];
    //Create an array of the elements that the heading will require a wider heading
    $fourSpanElements = array(
                              "tbl_inspections_95_repeat___tp_0_0"
                              ;


    //Create an array of elements that the heading will need to be not displayed so that the table displays correctly
    $standardElements = array(
                              "tbl_inspections_95_repeat___tp_1_0",
                              "tbl_inspections_95_repeat___tp_2_0",
                              "tbl_inspections_95_repeat___tp_3_0"
                              );


    foreach ($firstGroup as $el) :
        $style = $el->hidden ? 'style="display:none"' : '';
        //make the title span 4 elements and centralise the text  
        if (in_array($el->id, $fourSpanElements)) {
           $span = "colspan = 4;";
           $align = 'style="text-align:center;"';
        //hide the labels
        }elseif(in_array($el->id, $standardElements)){
           $style ='style="display:none"';
        }
        ?>

        <th <?php echo $style; ?> <?php echo $align; ?> <?php echo $span;?>class="<?php echo $el->containerClass?>">
            <?php echo $el->label_raw?>
        </th>
        <?php
    endforeach;

The result is that the heading for 'tbl_inspections_95_repeat___tp_0_0' covers four elements in total and is centered on them.
 
Last edited:
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top