Panda Pods Repeater Field

Descripción

Panda Pods Repeater Field is a plugin for Pods Framework. The beauty of it is that it is not just a repeater field. It is a quick way to set up a relational database and present the data on the same page. It takes the advantage of Pods table storage, so you don’t need to worry that the posts and postmeta data table may expand dramatically and slow down page loading. This plugin is compatible with Pods Framework 2.8 or later. To download Pods Framework, please visit http://pods.io/. After each update, please clear the cache to make sure the CSS and JS are updated. Usually, Ctrl + F5 will do the trick.

Introduction


Capturas

  • After the activation of Pods Framework, please also activate Advance Content Type and Table Storage in Pods Admin, under the Components section.
  • Activate Advance Content Type.
  • Activate Table Storage.
  • Here, you will learn how to use it through an example. First, we have to add a new Pod. In Pods, please click Create New.
  • and create a new Pod with Advance Content Type. In this tutorial, we call it "Comic Content"
  • We are going to use Comic Content as the storage of a repeater field.
  • Under the Admin UI tab, untick Show Admin Menu in Dashboard, because if you add an item to it, it is not linked to any parent posts.
  • Now we create a new post type in Pod. We name it "Comic" and we use Table Based storage, because we want to reduce the burden of the WordPress Posts table.
  • Once it has been created, we add a new field to Comic. We name it "Comic Box 1" here. At the bottom of the Field Type, you will find Pods Table As Repeater Field. Select it and then click the tab "Additional Field Options".
  • Now you can see a Pods Table "comic_content" we just created in the combo box. Select it, add or update the field and save Pod. You can set field width, defaulted to 100%. You can also limit the number of entries of the repeater field. Enable Trash will allow you to move items to Trash and Restore them if you still want them. Trashed items won't be pulled out by pods_field() and pandarf_items_fn(), but if you diable Trash later on, the trashed items will still be pulled out. There are other advanced options to choose. They should be self-explanatory.
  • If you are doing nested repeater fields, I recommend you set it to 100%. A sample of nested repeater fields.
  • OK, the set up is done. Now if you are adding a new Comic,
  • you will see "Comic Box 1" in the More Fields area.
  • You can add as many new items to Comic Box 1 as you want, and they are only attached to the current Comic you are editing .
  • You can click top bar to contract it, the bottom bar to expand the window.
  • To find the parent_pod_id and parent_pod_field_id, go to Pods and click the main Pod (Comics in this tutorial).
  • Here, 2215 is parent_pod_id and 2222 is parent_pod_field_id
  • To find the parent_pod_post_id, open the main post and look at the URL. If you are using a Pods Adavnce Custom Type or a Custom Post Type as the main table, it is the "id" variable in the URL. If you add a repeater field to Settings, the parent post id is the same as parent_pod_id. If you add a repeater field to Users, the parent post id is the same as the user ID.
  • The Load More functionality settings.
  • Instructions for the Load More functionality.
  • The Order option settings.
  • Display Order Info.

Instalación

  1. Upload the plugin files to the /wp-content/plugins/panda-pods-repeater-field directory, or install the plugin through the WordPress plugins screen directly.
  2. Activate the plugin through the ‘Plugins’ screen in WordPress
  3. Use the Settings->Plugin Name screen to configure the plugin

FAQ

How to use it?

Please see the screenshots for instructions.

How to fetch data at the frontend

From Version 1.1.4, you can use pods_field(). e.g. in a single post template, pods_field( ‘field_name’ ) to fetch the data for the current page, otherwise use pods_field( ‘pods_name’, ‘post_id’, ‘field_name’ ) to fetch any data you want anywhere. To fetch data from the settings area, use pods_field( ‘pods_name’, false, ‘field_name’ ). To fetch data from the users area, use pods_field( ‘user’, ‘user_id’, ‘field_name’ ).

You can use the filters: pandarf_pods_field_attrs( array(), $value_ukn, $row_arr, $params_arr, $pods_obj ) and pandarf_data_attrs( array(), $data_arr, $parent_pod_name ) to alter the repeater data returned from pods_field().

From Version 1.1.6, if the field type is “file”, it will return the file ids, then use WordPress APIs like get_attached_file(), wp_get_attachment_image_src() etc to get the file details. Relation types of ‘user’, ‘post type’, ‘pod’ and ‘media’ will now return the saved ID.

You can also use this API to fetch data: pandarf_items_fn( $fields_arr, $attrs, $show_query ). Please see the Screenshots section for how to find ids.

$fields_arr search repeater field table
array(
‘id’ => ”, // row id
‘name’ => ”, // the common name field used by pods
‘child_pod_name’ => ”, // repeater table name
‘parent_pod_id’ => ”,// main table pod id
‘parent_pod_post_id’ => ”, // main table post id
‘parent_pod_field_id’ => ”, // main table pod Panda Pod Repeater Field id
)

$attrs for some basic mySQL commands (Optional)
array(
‘where’ => ”, // exter where, expected to be escaped
‘order’ => ‘ASC’,
‘order_by’ => ‘pandarf_order’,
‘group_by’ => ”,
‘start’ => 0,
‘limit’ => 0,
‘count_only’ => false, // if true, it will return the amount of rows in an array.
‘add_tb_prefix’ => true, // add $table_prefix to the table name. Default to ture
)

$show_query
If set to true, it will print out the sql command. For debugging purpose. Default to false.

An example of basic usage. IDs from the Screenshots section:
get_pandarf_items( array( ‘child_pod_name’ => ‘comic_item’, ‘parent_pod_id’ => 2273, ‘parent_pod_post_id’ => 2275, ‘parent_pod_field_id’ => 2274 ) );
or pandarf_items_fn before v1.4.11

It will return the items attached to the post from Comic Contents.

How to insert data at the frontend

You can use this API to insert data: pandarf_insert( $fields_arr, $prf_arr, $show_query ). Please see the screenshots for how to find ids.

$fields_arr extra fields other than panda repeater fields to insert:
array(
‘field_name’ => ”,
‘field_name’ => ”
… …
)
$prf_arr the default repeater fields
array(
‘child_pod_name’ => ”, // The name of the table for saving repeater field items.
‘parent_pod_id’ => ”, // main table pod id
‘parent_pod_post_id’ => ”, // main table post id
‘parent_pod_field_id’ => ”, // main table Panda Pods Pod Repeater Field id
‘user_id’ => 0 // The author id
‘add_tb_prefix’ => true, // add $table_prefix to the table name. Default to ture
)

$show_query
If set to true, it will print out the sql command. For debugging purpose. Default to false.

This API will return the wpdb inserted ID if successful, or false on failure.

An example of basic usage. IDs from the Screenshots section:
$id_int = pandarf_insert( array( ‘name’ => “hello panda” ), array( ‘child_pod_name’ => ‘comic_item’, ‘parent_pod_id’ => 2273, ‘parent_pod_post_id’ => 2275, ‘parent_pod_field_id’ => 2274, ‘user_id’ => $current_user->ID ) );

/**
* The repeater field is only for logged in users with edit_posts capability
* If you want it to be available for the frontend users, you can use this filter
*
* @param boolean $is_allowed allow the form to be displayed
* @param array $get_arr variables from $_GET
* @return boolean still allow or not
*/
function pprf_allow( $is_allowed, $get_arr ){

$pod_obj    =   pods('your_pod_slug');      
if( $get_arr['podid'] == $pod_obj->pod_id ){
    $is_allowed = true;
}
return  $is_allowed;

}

How to remove the CSS and JavaScript enqueued by the plugin at the frontend

Add this code to your functions.php

add_action( ‘wp_enqueue_scripts’, ‘dequeue_scripts_and_styles’, 11 );

function dequeue_scripts_and_styles() {
wp_dequeue_script( ‘panda-pods-repeater-scripts’ );
wp_dequeue_style( ‘panda-pods-repeater-general-styles’ );
wp_dequeue_style( ‘panda-pods-repeater-styles’ );
}

Reseñas

24 de marzo de 2023 1 respuesta
Overall a great plugin since Pods is still missing a repeater functionality that allows nested fields (like the ACF Repeater).However, the user interface of this plugin, especially for content editors, is just a big mess and would need a redesign. Oh and to anyone who stumbles upon this using Pods 2.9+ : It's important that you enable at least "Advanced Content Types" in "Pods Admin" > "Components" to follow the instructions of this plugin. I cannot believe how much time i wasted to find this setting. As a developer, i have a totally different understanding of what a "Component" is and the Pods documentation just sucks.
22 de diciembre de 2021 2 respuestas
Utilizing this plugin, you're able to use your Pods in a mind-blowing way, which to me was so much better than trying the other ones! Also, if you need any questions, you'll get your answers in a jiffy by the authors, which is fantastic!
25 de noviembre de 2020 1 respuesta
Le plugin fonctionne parfaitement. Il permet de mettre en place une répétition de champs avec PODS. Merci aux contributeurs pour mise à disposition de cet outil librement. +++
13 de noviembre de 2017 2 respuestas
unable to get the data from repeater fields follow every steps as shown in the images instruction ,i made the Advanced Content Type (project_image) and create two fields for repeater 1.project_image 2.position and add this in custom post type (project), i added the field Pods Table As Repeater Field (projects_box) and choosed in additional field option project_image, everything is working fine but unable to fetch these fields data at frondend. kindly help me with this. Regards, Zeeshan
17 de septiembre de 2017 2 respuestas
Sorry, don't use Panda Pods, I know it's tempting but it has not passed the code review from pods (and they did a code review), it is doing things in a way that is about to break in 2.8, and repeatable fields is coming in 2.9 (hopefully arriving within 2017) Instead please use the new 2.7 relationships UI with add new and list view, it's light years ahead of anything else - https://www.youtube.com/watch?v=1h_5tQ6LmoY
Leer todas las 10 reseñas

Colaboradores y desarrolladores

«Panda Pods Repeater Field» es un software de código abierto. Las siguientes personas han colaborado con este plugin.

Colaboradores

Traduce «Panda Pods Repeater Field» a tu idioma.

¿Interesado en el desarrollo?

Revisa el código , echa un vistazo al repositorio SVN o suscríbete al registro de desarrollo por RSS.

Registro de cambios

1.0.1 – 23rd Sept 2016

  • Added: Added a filter to display item title

1.0.2 – 30rd Sept 2016

  • Added: Enable pandarf_items_fn to search id and name fileds
  • Added: Tell users to refresh pages after reordering

1.0.3 – 05th Oct 2016

  • Added: allow custom where query in pandarf_items_fn

1.0.4 – 06th Oct 2016

  • debug: update pandarf_parent_post_id to number only, it was string before

1.0.5 – 14th Oct 2016

  • debug: fixed the ordering for newly added items

1.0.6 – 21st Oct 2016

  • debug: fixed the problem on user profile page

1.0.7 – 28st Oct 2016

  • debug: fixed the problem when using it within Advance Custom Type

1.0.8 – 2nd Nov 2016

  • debug: fixed the problem when order by pandarf_order at the frontend, cast string as number

1.0.9 – 2nd Nov 2016

  • debug: changed time from h:i:s to H:i:s

1.1.0 – 1st Dec 2016

  • add: add param – add_tb_prefix to API pandarf_items_fn() and pandarf_insert so they can be used for all tables
  • add: add action pods_post_delete() to pods_api_post_delete_pod_item
  • add: add action pprf_action_pods_post_delete() to pods_post_delete
  • add: add filter pprf_filter_pods_post_delete() to pods_api_post_delete_pod_item
  • add: add action pprf_action_pods_post_save() to pods_post_save
  • add: add filter pprf_filter_pods_post_save() to pods_api_post_delete_pod_item
  • add: auto-expanding when add and edit an item
  • add: improved interface

1.1.1 – 4th Mar 2017

  • debug: fixed the problem: after deleting an item, the label still stayed
  • add: improved interface

1.1.2 – 22nd April 2017

  • add: new close and expand bars on the top and bottom
  • change: moved the delete button from the iframe to the parent window
  • change: simplified re-order

1.1.3 – 13nd May 2017

  • add: a Save button on the bar
  • debug: fixed the problem when insert pandarf_order at the frontend, cast string as number
  • debug: remove add_action( ‘save_post’, array( $tableAsRepeater_cla, ‘update_child_pod’ ), 10, 3 ), not needed any more

1.1.4 – 29th June 2017

  • add: API to check if a field is a Panda Pods Repeater Field is_pandarf_fn( $fieldName_str )
  • add: API to fetch repeater data for a data row from a database table pandarf_get_data( $data_arr, $parent_pod_name )
  • add: Integrated with pods_field()

1.1.5 – 09th July 2017

  • debug: fixed the problem: newly created item fetched data from other parent posts when using pods_field

1.1.6 – 05th August 2017

  • add: Now return file and user ids for relation types of ‘user’, ‘post type’, ‘pod’ and ‘media’
  • add: Now you can limit the number of entries

1.1.7 – 19th August 2017

  • debug: fixed the problem if the number of entries was set to 0, the “Add New” would disappear.

1.1.8 – 15th October 2017

  • debug: Now use pods_register_field_type() to register Panda Pods Repeater Field.
  • debug: Fixed some styling problems
  • debug: Fixed the pods relationship fields ordering problem
  • add: Now give alerts if changes not saved

1.1.9 – 22nd October 2017

  • debug: Fixed the problem that expanding and contrasting call the pprf_resize_window() too many times and sometimes the iframe was not ready.
  • add: Now items can be moved to trash and restored from trash

1.2.0 – 17nd December 2017

  • change: Now saving table post_name instead of ID to solve the problem of migration. It won’t affect the saved data, but you will have to update the field in Pods – pick the right one again in order to migrate properly.
  • debug: fixed the problem that when using the same field name in two tables, it didn’t bring back the right data.

1.2.1 – 5th March 2018

  • change: Enhanced ajax security
  • add: added support for frontend pods form
  • fixed: newly added item could only be deleted, not trashed

1.3.0 – 27nd July 2018

  • add: added load more functionality
  • add: added order options
  • add: re-order will update colours
  • change: changed some code according to Pods official reviews

1.3.1 – 19th August 2018

  • change: changed drag and drop tolerance from “pointer” to “intersect”
  • debug: fixed a problem when Enable Load More was set to No, only ten items were loaded

1.3.2 – 23rd September 2018

  • debug: fixed the date field not displaying problem

1.3.3 – 29th October 2018

  • debug: somehow pods->delete() didn’t work, use $wpdb query for now

1.3.4 – 03rd November 2018

  • debug: fixed the problem for pods->delete()
  • add: now Admin Table Columns can be used for labels

1.3.5 – 18th November 2018

  • debug: fixed the problem when the order field was changed, the pandarf_items_fn function didn’t respond to it
  • debug: fixed a typo

1.3.6 – 19th November 2018

  • debug: fixed the problem when the order field was empty, it loaded data descendingly
  • change: adjusted some icons’ padding and margin

1.3.7 – 9th December 2018

  • debug: fixed the problem pods_field() didn’t fetch data in ajax

1.3.8 – 10th March 2019

  • add: optimised some code
  • add: allow an item to be reassigned to another parent, a field using the same child table.

1.4.0 – 24th March 2019

  • change: changed the way a repeater field is rendered out so it can be brought out at frontend for not logged in users.
  • change: changed filter names from “pprf_load_panda_repeater_allow” to “pprf_load_panda_repeater_allow_input”, “pprf_load_panda_repeater_allow_msg” to “pprf_load_panda_repeater_allow_input_msg”.
  • change: JavaScript ‘live’ to ‘on’.
  • add: allow chosen user roles to access the field.
  • fix: The field was opened and closed immediately on mobile.

1.4.1 – 20th April 2019

  • change: Made JavaScript alerts translatable.
  • add: Chinese language support.
  • fix: error when a Pods table did not exist.
  • fix: error on multisites.
  • fix: error when a repeater field is a custom post type, although using a custom post type as a repeater field is not part of the plan.

1.4.2 – 27th May 2019

  • add: added a filter pandarf_pods_field_fields.

1.4.3 – 22th June 2019

  • add: locked down the font size in the form so it won’t be affected by the theme
  • change: changed $pods_obj->id to $pods_obj->id() in pandarf_pods_field() to fix the problem in rest api

1.4.4 – 22ND September 2019

  • fix: TypeError: Backbone.Marionette is undefined
  • fix: $(…).live is not a function error using jquery

1.4.5 – 2nd November 2019

  • add: Added some code to add the relationship fields if they are missing. Useful for migrating the repeater fields or create them by code.
  • fix: the $ not a function problem when clicking the Load button.
  • Change: Resize the window after running all JavaScripts.

1.4.6 – 4th February 2020

  • fix: Fixed the problem that the trash, save and edit buttons had to be clicked twice on mobiles to work.
  • add: some styling for the load more div.
  • add: Integration with Simpods Area Field.
  • add: Remove all tags from label outputs for security purpose and limit the label characters to 80. If a label contains images, videos, audio, shortcodes display relevant icons.

1.4.7 – 29th July 2020

  • fix: Fixed the problem that the database class was not included in the pandarf_items_fn function.

1.4.8 – 9th December 2020

  • add: Catch up with Simpods 3.0.0 on area field
  • add: Minified CSS and JavaScript files.
  • add: add a filter load_pprf_scripts_frontend to toggle loading PPRF scripts and styles at the front end.
  • add: added more frontend css.
  • fix: some JavaScript to catch up with WordPress 5.6 update

1.4.9 – 7th March 2021

  • change: use index.php for pandarepeaterfield.php.
  • change: changed click() to trigger(‘click’).
  • change: Reassign can also work for parent table with meta storage type.
  • change: caught up with the change of wp_localize_script in WordPress 5.7
  • add: Pods 2.8 use parent intead of pod_id. This verson catches up with this change.
  • fix: A bug in the order query.

1.4.10 – 30th March 2021

  • add: When displaying labels with admin columns, if it is a simple relationship, display labels instead of values.
  • fix: A bug when using PHP 8

1.4.11 – 21th October 2021

  • change: Caught up with the changes in Pods 2.8

1.5.0 – 21th October 2021

  • change: Removed _fn afterfix in function names and update a lot of variable names to match WordPress coding standards.
  • fix: Fixed the problem when a pod_index exisits in the postmeta table but not used as a field in the pod table.
  • add: use the cache of simpods_tables if available, to avoid the duplications of the query
  • add: use WordPress cache for checking if it is a panda pods repeater field
  • add: When a new entry is added, it will use the admin columns if required.

1.5.1 – 12th February 2022

  • fix: Fixed the sorting problem because of WordPress 5.9.

1.5.2 – 26th March 2022

  • fix: Fixed the sorting problem in settings because of WordPress 5.9.
  • fix: Fixed the problem that pandarf_insert couldn’t insert files.
  • fix: Fixed the integration problem after Pods 2.8
  • fix: Fixed the problem that the “Please save the parent first” message stopped appearing.
  • fix: Fixed the problem that the child pod became available when the parent was not saved.
  • fix: Fixed the problem that a newly added item couldn’t display admin columns

1.5.3 – 4th December 2022

  • add: pprf_parent_filter_conditions() to filter the parents dropdown for reassignment and duplication
  • add: Added a duplication funtionality
  • add: Added a funtionality to delete item descendants: when a parent item is deleted, all its descendants will be deleted too.
  • add: Added a constant to toggle the functionality of deleting item descendants to ensure users get the message that backups should be created before using it.
  • add: Added IDs to the parents dropdown list.

1.5.4 – 6th December 2022

  • update: Applied coding standards.

1.5.5 – 22th December 2022

  • update: Applied more coding standards.

1.5.6 – 23th December 2022

  • update: Applied more coding standards.

1.5.7 – 23th December 2022

  • update: Applied more coding standards.

1.5.8 – 29th December 2022

  • remove: Removed the frontend access.

1.5.9 – 29th December 2022

  • update: Re-organised the positions of some code.

1.5.10 – 12th February 2023

  • fix: Fixed the problem that the custom database fields were not created after Pods 2.7.

1.5.11 – 30th April 2023

  • fix: Fixed the problem that items were fetched from trash as well.
  • update: Removed the instructions to use the repeater form at the frontend.