- This topic has 2 replies, 2 voices, and was last updated 6 years, 4 months ago by
Steve.
-
AuthorPosts
-
-
October 11, 2015 at 2:20 am #4528
Mehdi SalemMemberHi,
I have some Piklist group add_more fields (se code bellow). I access these fields data from my custom theme. Any newly saved group add_more fields are not accessible anymore from my custom functions… Looking at the database shows that what used to be saved by Piklist 0.9.5v like this:
a:4:{ s:12:"single_photo";a:2:{i:0;a:1:{i:0;s:3:"162";}i:1;a:1:{i:0;s:3:"160";}}s:11:"photo_title";a:2:{i:0;s:4:"test";i:1;s:4:"test";} s:18:"store_availability";a:2:{i:0;a:1:{i:0;s:0:"";}i:1;a:1:{i:0;s:0:"";}}s:17:"photo_description";a:2:{i:0;s:4:"test";i:1;s:4:"test";} }Is now saving this way:
a:2:{ i:0;a:4:{s:12:"single_photo";a:1:{i:0;s:3:"162";}s:11:"photo_title";s:4:"test";s:18:"store_availability";a:1:{i:0;s:0:"";}s:17:"photo_description";s:4:"test";} i:1;a:4:{s:12:"single_photo";a:1:{i:0;s:3:"160";}s:11:"photo_title";s:4:"test";s:18:"store_availability";a:1:{i:0;s:0:"";}s:17:"photo_description";s:4:"test";} }This is a problem because it will break any custom code…
for example I used to get the first image file of add_more field this way:$folder_content = get_post_meta($post_id, 'folder_content_group', TRUE); $photo_id = $folder_content['single_photo'][$_SESSION['photo_count']][0];Now all I’m getting are undefined indexes… and I have to update all my fields and all my custom code as well like this to get my theme to work:
$folder_content = get_post_meta($post_id, 'folder_content_group', TRUE); $photo_id = $folder_content[$_SESSION['photo_count']]['single_photo'][0]' I admit this is an improvement, it is more intuitive now because data is saved as an add_more serialized array now rather than based on fields first You might be aware of this already but just in case: this might be a big problem for custom production sites because even if you have a script that'll update all fields, the tricky part will be each developer custom code... Perso, as long as this is not going to change again, I'm fine, since I do not have huge stuff in production yet I support you anyways in this adventure that'll move us out of beta soon Cheers! MY GROUP ADD_MORE FIELDS:<?php
/*
Title: Content
Post Type: post
Order: 20
*/piklist(‘field’, array(
‘type’ => ‘group’
,’field’ => ‘folder_content_group’
,’label’ => __(‘Gallery Photo’,’stopping-the-world-admin’)
,’description’ => __(‘Add photos to this folder.’, ‘stopping-the-world-admin’)
,’help’ => __(‘Adds a new photo to this gallery folder and sets its availability on the store.’,’stopping-the-world-admin’)
,’add_more’ => true
,’fields’ => array(
array(
‘type’ => ‘file’
,’field’ => ‘single_photo’
,’label’ => __(‘Photo’,’stopping-the-world-admin’)
,’options’ => array(
‘modal_title’ => __(‘Add a Photo’,’stopping-the-world-admin’)
,’button’ => __(‘Add’,’stopping-the-world-admin’)
)
,’required’ => true
/*,’validate’ => array(
array(
‘type’ => ‘limit’,
‘options’ => array(
‘min’ => 1,
‘max’ => 1
)
)
,array(
‘type’ => ‘image’
)
)*/
)
,array(
‘type’ => ‘text’
,’field’ => ‘photo_title’
,’label’ => __(‘Title’,’stopping-the-world-admin’)
,’help’ => __(‘Sets the photo title. This will appear bellow the photo and above the description on the Gallery Foolder post.’,’stopping-the-world-admin’)
,’columns’ => 7
,’attributes’ => array(
‘placeholder’ => __(‘Enter photo title here…’, ‘stopping-the-world-admin’)
)
)
,array(
‘type’ => ‘checkbox’
,’field’ => ‘store_availability’
,’label’ => __(‘Store Availability’,’stopping-the-world-admin’)
,’help’ => __(‘(Leave unchecked if you do not want to sell this photo.)’,’stopping-the-world-admin’)
,’columns’ => 5
,’choices’ => array(
‘option1’ => ‘Sell Stock’
,’option2′ => ‘Sell Print’
)
)
,array(
‘type’ => ‘textarea’
,’field’ => ‘photo_description’
,’label’ => __(‘Description’,’stopping-the-world-admin’)
,’help’ => __(‘Sets the photo description. This will appear bellow the photo and its title on the Gallery Folder post.’,’stopping-the-world-admin’)
,’attributes’ => array(
‘rows’ => 5
,’cols’ => 50
,’placeholder’ => __(‘Describe this photo…’, ‘stopping-the-world-admin’)
,’maxlength’ => ‘320’
)
)
)
));`
-
October 11, 2015 at 2:26 am #4529
Mehdi SalemMemberSorry, I omitted a
codetag so reposting last part:I admit this is an improvement, it is more intuitive now because data is saved as an add_more serialized array now rather than based on fields first
You might be aware of this already but just in case: this might be a big problem for custom production sites because even if you have a script that’ll update all fields, the tricky part will be each developer custom code…
Perso, as long as this is not going to change again, I’m fine, since I do not have huge stuff in production yet
I support you anyways in this adventure that’ll move us out of beta soon
Cheers!
MY GROUP ADD_MORE FIELDS:
<?php /* Title: Content Post Type: post Order: 20 */ piklist('field', array( 'type' => 'group' ,'field' => 'folder_content_group' ,'label' => __('Gallery Photo','stopping-the-world-admin') ,'description' => __('Add photos to this folder.', 'stopping-the-world-admin') ,'help' => __('Adds a new photo to this gallery folder and sets its availability on the store.','stopping-the-world-admin') ,'add_more' => true ,'fields' => array( array( 'type' => 'file' ,'field' => 'single_photo' ,'label' => __('Photo','stopping-the-world-admin') ,'options' => array( 'modal_title' => __('Add a Photo','stopping-the-world-admin') ,'button' => __('Add','stopping-the-world-admin') ) ,'required' => true /*,'validate' => array( array( 'type' => 'limit', 'options' => array( 'min' => 1, 'max' => 1 ) ) ,array( 'type' => 'image' ) )*/ ) ,array( 'type' => 'text' ,'field' => 'photo_title' ,'label' => __('Title','stopping-the-world-admin') ,'help' => __('Sets the photo title. This will appear bellow the photo and above the description on the Gallery Foolder post.','stopping-the-world-admin') ,'columns' => 7 ,'attributes' => array( 'placeholder' => __('Enter photo title here...', 'stopping-the-world-admin') ) ) ,array( 'type' => 'checkbox' ,'field' => 'store_availability' ,'label' => __('Store Availability','stopping-the-world-admin') ,'help' => __('(Leave unchecked if you do not want to sell this photo.)','stopping-the-world-admin') ,'columns' => 5 ,'choices' => array( 'option1' => 'Sell Stock' ,'option2' => 'Sell Print' ) ) ,array( 'type' => 'textarea' ,'field' => 'photo_description' ,'label' => __('Description','stopping-the-world-admin') ,'help' => __('Sets the photo description. This will appear bellow the photo and its title on the Gallery Folder post.','stopping-the-world-admin') ,'attributes' => array( 'rows' => 5 ,'cols' => 50 ,'placeholder' => __('Describe this photo...', 'stopping-the-world-admin') ,'maxlength' => '320' ) ) ) )); -
October 13, 2015 at 10:38 am #4544
-
-
AuthorPosts
- The topic ‘Pl 0.9.9.2 change in way group add_more fields are saved is breaking custom code’ is closed to new replies.