Panda Pods Repeater Field

Panda Pods Repeater Field

توسط

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


  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

سوالات متداول

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’ );
}

×
نظری برای این آیتم موجود نیست.
0 0 رای ها
امتیازدهی
اشتراک در
اطلاع از
0 نظرات
قدیمی‌ترین
تازه‌ترین بیشترین رأی
هیچ نسخه‌ای برای این آیتم موجود نیست.
★★★★★
★★★★★
4.5 /5 (11 نظر)

قیمت:

رایگان

نگارش

آخرین انتشار

15 اردیبهشت 1405

آخرین بروزرسانی

3 ماه پیش

نصب های فعال

600+

نگارش وردپرس

وردپرس 3.8+

تست شده از نسخه

وردپرس 6.5.8

نگارش PHP

-

نسخه ها

0 نسخه