WordPress.org

Ready to get started?Download WordPress

Forums

Participants Database
[resolved] database group (19 posts)

  1. waxsolutions
    Member
    Posted 11 months ago #

    Hi,

    Is there a way to show only a specific group or groups on the signup, using the templates?
    If so, what is the code line that I might need to put on the template?

    I tried:
    <?php while ( $this->have_groups() ) : this->the_group('services'); ?>

    as 'services' is the name of my specific group.

    thank you for your help.

    Johann

    http://wordpress.org/extend/plugins/participants-database/

  2. PayBas
    Member
    Posted 11 months ago #

    Can't you simply use the checkboxes in the "signup" column on the "manage database fields" admin page?

  3. waxsolutions
    Member
    Posted 11 months ago #

    hi,
    yes I could but i only want a specific groups to show on the signup and on a other page another group...

    the only way to do that will be for me to use the templates, but i need the template to call the right group instead of all of them.

    thanks for your help

  4. cbrendlinger
    Member
    Posted 11 months ago #

    You would need a separate template for each of the sign up forms that you want to display.

    There is code already in place on the templates that will allow you to exclude fields. So, Instead of excluding fields, just exclude certain groups. Define an array that excludes the group name(s) that you don't want to print:

    $exclude_title = array('nameofyourgroup');

    Then, you can check for the group name in your array and just exit the group while loop and move to the next one if they match by adding this if statement:

    <?php if (in_array($this->group->name, $exclude_title) ) continue; ?>
    
    <?php while ( $this->have_groups() ) : $this->the_group(); ?>
    
      <?php if ( $this->group->printing_title() ) : // are we printing group titles and descriptions? ?>
        <tr class="signup-group">
          <td colspan="2">
    
          <?php if (in_array($this->group->name, $exclude_title) ) continue; ?>
          <?php $this->group->print_title() ?>
          <?php $this->group->print_description() ?>
    
          </td>
        </tr>
      <?php endif; // end group title/description row ?>

    [Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]

  5. waxsolutions
    Member
    Posted 11 months ago #

    cbrendlinger,

    Thank you it works like a charm.

    Have a nice weekend!

    Johann

  6. cbrendlinger
    Member
    Posted 11 months ago #

    That's fantastic! Hope a good weekend for you too!

  7. waxsolutions
    Member
    Posted 11 months ago #

    Thank you cbrendlinger...

    I just realised that the piece of code only works for the signup template.
    I tried to use it for the [pdb-record] & [pdb-single] but it doesn't work...
    any idea?

    thanks a million

    Johann

  8. xnau
    Member
    Plugin Author

    Posted 11 months ago #

    Johann,

    Not sure exactly what you want to do here, but you can set which fields are shown in the shortcode like this:

    [pdb_record fields='last_name,first_name,email']

    Perhaps that makes it easier for you--this will work on all shortcodes.

  9. cbrendlinger
    Member
    Posted 11 months ago #

    Johann,

    ok... What I did for the pdb-single was to define two arrays... one for each of my groups (I only use two). The first array contains a list of fields that I exclude from group 1 and the second array contains a list of fields that I exclude from group 2 because otherwise all fields would print from both groups.

    &exclude_group1=array('field1', 'field2');
    &exclude_group2=array('field3', 'field4');

    Then I determine which group I am working with so that I can display the correct fields:

    <?php if ($this->record->main->fields->type->value != 'group1') $myarray = $exclude_group2;
    else $myarray = $exclude_group1; ?>

    And then this piece of code further down will check the fields properly (should already be in the template):

    'if (in_array($this->field->name, $myarray)) continue;'

    I do something similar for the pdb-record. I hope this helps and is the solution you are seeking if the shortcode above doesn't work for you. Let me know.

    Christi

  10. waxsolutions
    Member
    Posted 11 months ago #

    Xnau,

    Thank you for the reply.
    What I need to do is to use the same database but showing certain group on the signup page using templates. But I got that sorted with cbrendlinger...

    The problem now is for me to be able to update the record but only show the relevant group.
    example:
    group1 for admin; group2 for credit control
    i want admin staff to input and edit "Admin" group only
    and credit control staff to input or edit "Credit" group only

    at the moment i am stuck with the [pdb-record] & [pdb-single] templates. I need more than just the filed to be excluded.

    Thanks for your reply.

    Johann

  11. waxsolutions
    Member
    Posted 11 months ago #

    Christi,

    What you have just email me work well for fields but I need the whole group to be excluded as I explain above to Xnau.

    I will try that today and see...

    I will let you know how it went, Thanks.

    Johann

  12. cbrendlinger
    Member
    Posted 11 months ago #

    Johann,

    I excluded every field in group1 from group2 and vice versa. So, the final outcome looked like I had excluded the group but I actually excluded all of the fields for the group. It wa a little cumbersome but I got the results I needed.

    Christi

  13. alexdex
    Member
    Posted 11 months ago #

    Hi, can you help me about this modify? It is possible to have the code of pdb record template modify?
    I try and i have no results
    Thanks a lot

  14. alexdex
    Member
    Posted 11 months ago #

    Hi cbrendlinger
    Sorry, i try to change the pdb record template for show only some group.
    So, i see that pdb-single template have the possibility to use array but how is possible to make the same for pdb record and signup?

    Which is the correct code and in wich position?

    Please help me, i try a lot but i have no results.

    In the page of frontend i use this shortcode for call the new template:
    [pdb_list fields="private_id,email" search="true" sort="true" display_count="true" orderby="date_updated" order="desc" pdb_record template="mytemplatetest"]

    Thank you

  15. cbrendlinger
    Member
    Posted 11 months ago #

    Dear alexdex,

    I am not really sure what you are asking. pdb_list provides a list of the records in your database. pdb_record is used to edit an individual record based on the private_id. pdb_single is just used to display a single record and is visible to others.

    You have to have a separate pdb_signup template for each of your groups.

    For pdb_record, I do the same thing that I do with pdb_single. I create arrays that contain the fields that I don't want to display for each group. Then set the array accordingly.

    <?php if ($this->record->main->fields->type->value != 'Group1') $myarray = $exclude_group1;
    else $myarray = $exclude_group2; ?>

    ... and so on ...

    <?php
      while ( $this->have_groups() ) : $this->the_group(); ?>
    
        <table  class="form-table">
    
          <?php
          // step through the fields in the current group
    
          while ( $this->have_fields() ) : $this->the_field(); 
    
              // skip any field found in the exclude array
              if (in_array($this->field->name, $myarray)) continue; ?>
    
          <tr class="<?php $this->field->print_element_class() ?>">

    ... and so on ...

    I hope this gets you pointed in the right direction.

    Christi

  16. alexdex
    Member
    Posted 11 months ago #

    Thanks a lot
    I make the test and after i write the result

    BEST

  17. waxsolutions
    Member
    Posted 11 months ago #

    Hi Xnau & Chriti,

    I tried both your options guys and the i like the one that works directly with the shortcode...

    But... It only delete the fields and not the group.
    My problem is the title of the groups still show on the page.
    I need it to be gone too...

    any more insight guys?

    Johann

  18. xnau
    Member
    Plugin Author

    Posted 11 months ago #

    Groups can be set to not display in the settings...go to "manage database fields" on the "field groups" tab uncheck "display" on the group you don't want to show.

    If you don't want to do that (like if you want the group visible in other places) you can skip the group the same way you skip a field...put this after the line with "$this->the_group()"

    <?php if ($this->group->name == 'personal') continue; ?>

    Then you won't have to do anything to the fields inside that group.

  19. waxsolutions
    Member
    Posted 11 months ago #

    thanks that's all I needed.

Reply

You must log in to post.

About this Plugin

About this Topic