database group
-
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
https://www.ads-software.com/extend/plugins/participants-database/
-
Can’t you simply use the checkboxes in the “signup” column on the “manage database fields” admin page?
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
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.]
cbrendlinger,
Thank you it works like a charm.
Have a nice weekend!
Johann
That’s fantastic! Hope a good weekend for you too!
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
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.
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
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 onlyat 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
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
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
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 lotHi 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
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
Thanks a lot
I make the test and after i write the resultBEST
- The topic ‘database group’ is closed to new replies.