have_groups() iterator has no rows
-
The PDb_Shortcode::have_groups method returns a boolean which tells you whether all the groups have been iterated through or not.
In the template, the iterator is $this->record for single and record shortcodes.
Not seeing anything come back from that. I don’t have a lot of experience with this plugin, or WP to be honest, just trying to help someone out. Here’s the template code that’s not showing anything. Anything jump out?
<?php $admin_mode = false; // set this to true to enable admin mode $postmeta = get_post_meta(get_queried_object_id()); $readonly_fields = explode(',', str_replace(' ', '', current($postmeta['readonly_fields']))); $admin_fields = explode(',', str_replace(' ', '', current($postmeta['admin_fields']))); $admin = $admin_mode ? current_user_can('manage_options') : false; ?> <div class="wrap <?php echo $this->wrap_class ?>"> <?php // output any validation errors $this->print_errors(); ?> <?php // print the form header $this->print_form_head() ?> <?php while ($this->have_groups()) : $this->the_group(); ?> <?php $this->group->print_title() ?> <?php $this->group->print_description() ?> <table class="form-table"> <tbody class="field-group field-group-<?php echo $this->group->name ?>"> <?php while ($this->have_fields()) : $this->the_field(); if (!$admin && in_array($this->field->name, $readonly_fields)) { $this->field->readonly = 1; } else { $this->field->readonly = 0; } if ($admin || !$admin && !in_array($this->field->name, $admin_fields)) : ?> <tr class="<?php $this->field->print_element_class() ?>"> <th><?php $this->field->print_label() ?></th> <td id="<?php $this->field->print_element_id() ?>" class="<?php echo $this->field->readonly === 1 ? 'readonly-field' : '' ?>"> <?php if ($this->field->readonly && !$admin_field) { printf('<input type="hidden" name="%s" value="%s" />', $this->field->name, $this->field->value); echo PDb_FormElement::get_field_value_display($this->field); } elseif (!$admin_field) { $this->field->print_element(); } ?> <?php if ($this->field->has_help_text()) : ?> <span class="helptext"><?php $this->field->print_help_text() ?></span> <?php endif ?> </td> </tr> <?php else : printf('<input type="hidden" name="%s" value="%s" />', $this->field->name, $this->field->value); endif; endwhile; ?> </tbody> </table> <?php endwhile; // group loop ?> <table class="form-table"> <tbody class="field-group field-group-submit"> <tr> <th><h3><?php $this->print_save_changes_label() ?></h3></th> <td class="submit-buttons"> <?php $this->print_submit_button('button-primary'); // you can specify a class for the button ?> </td> </tr> </tbody> </table><!-- end group --> <?php $this->print_form_close() ?> </div>So… perhaps it would be best if you explained what you’re trying to accomplish. I see a lot of unnecessary code in that template.
Fair enough. I’m trying to help someone who says that the edit link stopped working and upon further inspection the edit page doesn’t render anything.
The edit link issue: Based on my understanding of the plugin, you would need a template to get the edit link to work. Based on the history, this page hasn’t been updated in years, but I don’t see how the edit link would work:
[pdb_list orderby=”group_and_team_assignment” order=”asc” sort=”true” list_limit=”500″ search=”true” fields=”view_link,approved,group_and_team_assignment,position_assigned,first_name,last_name,email,date_to_report,edit_link”]Edit page not rendering issue: I updated the Single Record Page setting to point to the edit page and noticed no columns rendered. Upon further inspection I found that template above and noticed the group iterator wasn’t returning anything. But maybe it’s not rendering anything because of the first issue?
My goal was to fix what was supposedly once working, but it’s a bit of a mystery to me how this ever worked. Some added info – not all volunteer records display a view and edit link on the list and some have a URL vs VIEW or EDIT. I assume that’s just because some of the records don’t have EDIT or VIEW persisted in those fields. I’ll keep digging, but any pointers would be appreciated.
So, the [pdb_single] (for showing a record) and [pdb_record] (for editing a record) have different requirements for the URL that determines which record to show. If the URL is not correct, it will show a “record not found” message.
Read the plugin Quick Setup item in the admin menu to get an overview on how to set up the plugin so these links work as expected.
As to showing the edit links. First of all, it’s important to understand that this is about a Participants Database custom template, not a WP template. I suggest you go back to the original article and use the template provided there as your starting point.
Adding an Edit Record Link to the Frontend List
The shortcode you showed will not show the edit links because it does not call the special template. This is explained in the article.
The topic ‘have_groups() iterator has no rows’ is closed to new replies.