• Hi, great plugin, great documentation and great support, well done! I need a little help with layout please. I’m trying to build textfields such as those displayed by <?php $this->field->print_element(); ?> but displayed in a table.

    like this:

    <td><?php $weekly->print_element('this_field') ?></td>
    <td><?php $weekly->print_element('that_field') ?></td>

    The intention is to have a form that will display all the data that the user can go and add to each day of the week simply by clicking in the relevant textfield, updating the info and clicking save. It needs to be displayed in a table, not one above the other as in the standard record loop.

    Thanks! Cup a coffee coming your way.

    https://wordpress.org/plugins/participants-database/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author xnau webdesign

    (@xnau)

    OK, well there are probably several ways to do this, but I don’t have enough info to get too detailed.

    Most importantly, if you’re going to set up a form in a table, you need to decide what constitutes a row or column. It’s not clear to me what you’re looking for there.

    You can do this yourself, using custom templates, but you will need a solid understanding of HTML and some PHP. You would create a custom template, then change how the looping works to lay out your table. I imagine you could use grouping to help with the layout: each group could be one of your columns, for instance.

    Thread Starter pluggy

    (@pluggy)

    Thanks for your reply. I have managed to get this far by experimenting. I have created a template and put the <th> and <tr> outside the loop to get each group as a table row with each field as <td>. For the dummies (me), how would I modify while ($this->have_groups()) : $this->the_group(); to choose a group of groups to include (or exclude others)? I see you have built in an exclude for fields but I can’t see one for groups. I would like to have separate templates for user details and this form.

    The other way I could build the table would be if there is a way to reference each individual field by name, such as:

    <tr>
        <th scope="row">Carbs</th>
        <td><?php $weekly->print_field('monc') ?></td>
        <td><?php $weekly->print_field('tuec') ?></td>
        <td><?php $weekly->print_field('wedc') ?></td>
        <td><?php $weekly->print_field('thuc') ?></td>
        <td><?php $weekly->print_field('fric') ?></td>
        <td><?php $weekly->print_field('satc') ?></td>
        <td><?php $weekly->print_field('sunc') ?></td>
        <td></td>
      </tr>

    Except instead of just displaying the result, using something like $weekly->print_element to show the textfield so each field can be edited.

    Plugin Author xnau webdesign

    (@xnau)

    You can set which groups are included in the form by using the “groups” attribute in the shortcode and naming the groups you want to appear.

    Thread Starter pluggy

    (@pluggy)

    That works but can I select the group per loop ($this->have_groups()) : $this->the_group(); so I can format each differently? I tried <?php echo do_shortcode('[pdb_single template=loop groups=measurements]'); ?> but I get a “No record was found” error.

    Plugin Author xnau webdesign

    (@xnau)

    You have to do it with a conditional statement like you would for a field.

    <?php if ($this->group->name === 'measurements' ) : ?>

    It’s trickier because you have to include the fields loop in the code chosen by the condition.

    Another approach is to use a pure CSS solution, targeting the group by it’s class name.

    The “do_shortcode” won’t work unless the ID is in the URL or you tell it which record to show:

    <?php echo do_shortcode('[pdb_single template=loop groups=measurements record_id=22]'); ?>

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Layout help’ is closed to new replies.