Forum Replies Created
-
AuthorPosts
-
mcmasterMemberAlex, instead of
$max_past_orders_to_show = $app_settings['max_past_orders_to_show'][0];I recommend that you test the value and only index it if it’s an array.
I have a little utility function I use for situations like this. If you don’t like recursion you may want to rewrite it. 😉
/** * First Leaf * Finds the first non-array element (singular or object) * The key() function gives us the first key in the array */ public static function first_leaf ( $value ) { return !is_array( $value ) ? $value : first_leaf( $value[key($value)] ); }
mcmasterMemberp.s. tried to upload a .zip file of the Piklist parts file but it was rejected. I thought zip files were allowed?
form-test.php_.zip: Sorry, this file type is not permitted for security reasons.
mcmasterMemberMy problem was resolved with the release of v 0.9.9.16.
mcmasterMemberFYI … as I work through the new site, I’m finding that this affects everywhere that I’m using previously defined meta-boxes that contain images (file fields).
mcmasterMemberI have a similar situation but it’s not caused by an old database, rather old code and a new database.
I just created a new WP site. I installed Piklist version 0.9.9.15. I am using a meta-box to define a row with 3 columns or “features.” Each feature has a headline, image, text.
piklist( 'field', array( 'type' => 'group', 'field' => 'panel_features', 'label' => 'The three features for this panel', 'description' => 'Enter content for features. The quantity should be a multiple of 3.', 'columns' => 12, 'add_more' => true, 'fields' => array( array( 'type' => 'text', 'field' => 'feature_headline', 'label' => 'Headline', ), array( 'type' => 'file', 'field' => 'feature_image', 'label' => 'Select Image', 'options' => array( 'modal_title' => 'Add Image', 'button' => 'Add', ), ), array( 'type' => 'editor', 'field' => 'feature_text', 'label' => 'Text', 'options' => array ( 'media_buttons' => false, 'textarea_rows' => 3, 'teeny' => true, 'quicktags' => true, ), ), ), ));This meta-box code is in a little plugin I created and is in use on several websites. I just copied the plugin to the new website and configured 3 features. But the images didn’t show up on the new site. I used piklist::pre and looked at the data. It looks fine but note that each image is a single ID, not an array:
Array ( [0] => Array ( [feature_headline] => Feature 1 [feature_image] => 14195 [feature_text] => Text for Feature 1. ) [1] => Array ( [feature_headline] => Feature 2 [feature_image] => 14194 [feature_text] => Text for Feature 2. ) [2] => Array ( [feature_headline] => Feature 3 [feature_image] => 14191 [feature_text] => Text for Feature 3. ) )But my code, which is working with the above fields on several existing websites, expects an array:
$image = wp_get_attachment_image( $feature['feature_image'][0], $image_size, false );When I added a second image to one of the features, it replaced the feature image instead of being added to an array.
In fact I prefer the new behavior because the file sub-field is not an add-more so it feels more correct and is simpler. My concern is that it is a change from previous behavior and I’m really concerned that old sites are going to break. Should I run a conversion on the old sites? Do I need to go back and edit code?
Thanks!
Donna
mcmasterMemberGlad it worked for you!
mcmasterMemberHi @conkid,
I’m running the Piklist 0.10 Beta from Github, which has so far shown itself to be robust and bug-free. Your problem seems to be fixed there (see image).
Two observations: I’m assuming that you know you have two copies of the Owner field. 😉
And I am impressed that you’re able to make sense of code that isn’t consistently formatted. I reformatted it because I wanted to see what you’re doing and because I’m OCD. An unsolicited suggestion from this old programmer: consider creating the user list arrays as variables before defining the field, and then just reference the variables within the field definition. It will make your code easier to follow.
<?php /* Title: Details Post Type: post Priority: high Context: normal */ piklist('field', array( 'type' => 'group', 'label' => 'Ticket Details', 'template' => 'field', 'fields' => array( array( 'type' => 'number', 'field' => 'ticket_number', 'label' => 'ID', 'columns' => 2, 'attributes' => array( // Pass HTML5 attributes in the attributes array 'placeholder' => 'Ticket #', 'readonly' => 'readonly', ) ), array( 'type' => 'select', 'field' => 'ticket_user', 'label' => 'User', 'columns' => 2, 'choices' => array( '' => '-Select-' ) + piklist( get_users( array( 'orderby' => 'display_name', 'order' => 'asc', 'exclude' => '2' ), 'objects' ), array( 'ID', 'display_name' ) ) ), array( 'type' => 'select', 'field' => 'ticket_priority', 'label' => 'Priority', 'columns' => 2, 'choices' => array( '' => '-Select-', 'priority_one' => '1 - Urgent - Critical Impact (Priority One)', 'priority_two' => '2 - High - Significant Impact (Priority Two)', 'priority_three' => '3 - Normal/Minor impact (Priority Three)', 'priority_four' => '4 - Low/Informational (Priority Four)', ) ), array( 'type' => 'datepicker', 'field' => 'ticket_start_date', 'label' => 'Start Date', 'columns' => 2, 'attributes' => array( // Pass HTML5 attributes in the attributes array 'required' => 'required', ) ), array( 'type' => 'datepicker', 'field' => 'ticket_end_date', 'label' => 'End Date', 'columns' => 2, 'attributes' => array( // Pass HTML5 attributes in the attributes array ) ), array( 'type' => 'select', 'label' => 'Ticket Details', 'field' => 'ticket_support_type', 'columns' => 2, 'choices' => array( '' => '-Select-', 'Hardware' => 'Hardware', 'priority_two' => '2 - High - Significant Impact (Priority Two)', 'priority_three' => '3 - Normal/Minor impact (Priority Three)', 'priority_four' => '4 - Low/Informational (Priority Four)', ) ), array( 'type' => 'select', 'field' => 'ticket_owner', 'label' => 'Owner', 'columns' => 6, 'choices' => array( '' => 'Select' ) + piklist( get_users( array( 'orderby' => 'display_name', 'role__in' => array('information_technology', 'administrator'), 'order' => 'asc', 'exclude' => '2' ), 'objects' ), array( 'ID', 'display_name' ) ) ), array( 'type' => 'select', 'field' => 'ticket_owner', 'label' => 'Owner', 'columns' => 6, 'choices' => array( '' => 'Select' ) + piklist( get_users( array( 'orderby' => 'display_name', 'role__in' => array('information_technology', 'administrator'), 'order' => 'asc', 'exclude' => '2' ), 'objects' ), array( 'ID', 'display_name' ) ) ), ) ));Attachments:
You must be logged in to view attached files.June 10, 2017 at 6:12 pm in reply to: Is it possible to have a repeater with multiple text inputs? #8279
mcmasterMemberHi, @ brianeoneill, you’re on the right track but you’re missing a few pieces.
Your container field needs a type. You may also want to add labels for your sub-fields:
piklist('field', array( 'type' => 'group', // <== needed 'field' => 'music', // <== optional 'label' => 'Music', 'description' => 'Add songs from this episode', 'add_more' => true, 'fields' => array( array( 'type' => 'text', 'value' => 'song title', 'field' => 'song_title' 'label' => 'Title', // <== optional ), array( 'type' => 'text', 'value' => 'song artist', 'field' => 'song_artist' 'label' => 'Artist', // <== optional ), array( 'type' => 'text', 'value' => 'song url', 'field' => 'song_url' 'label' => 'URL', // <== optional ) ) ));See the example here for more details.
June 10, 2017 at 5:58 pm in reply to: Pretty Powerful Framework but when can we expect the stable version #8278
mcmasterMember@curiousprem, I’ve been using beta versions of Piklist on live sites for several years now. While there are occasional problems, they are not worse than most released plugins, and the benefits of Piklist have outweighed the occasional bugs.
I started using 0.10 when it was released almost two months ago, and it’s been remarkably solid. Most of the Piklist bugs that had plagued me have been fixed, and the new issues have been minor. So I just launched two more sites with Piklist 0.10 in the past two weeks, and am still able to sleep at night. 🙂
Donna
mcmasterMemberHi @saillandc, I’m not familiar with the HighEnd theme. It would help to know what results you’re looking for.
I find Piklist to be most useful for modeling, editing, and presenting data that is more than just pages or blog posts. For example, this native plants database.
It’s also useful when you want to create a custom theme that allows you to place content elements exactly where your design calls for them to be.
Are these the kind of features you are looking for?
Donna
mcmasterMember@openmic: Just a suggestion, if you put your code into the “code” tags supported by the forum editor, it will make it a lot easier for the volunteer helpers to see what’s going on. 🙂
mcmasterMemberThanks for clarifying; I was wondering why 0.9.9.13 wasn’t 0.10.x 😉
mcmasterMemberI agree with Jason. I answered this question in some detail in the WP Chat forum in November 2015.
I just re-read my answer, and wouldn’t change my conclusions. I know ACF just made a major release and I haven’t tested it to see if they’ve improved their architecture, but I have no reason to believe that it would serve me better than Piklist.
mcmasterMemberThanks so much, Steve! I’m installing it on my WIP sites right now.
Donna
mcmasterMemberFound sort of a workaround: my clients were having trouble with this bug as most shortcodes on the site are defined in Piklist so they aren’t easily editable.
So I rewrote the shortcodes not using Piklist and moved the parts files to an archive folder. But this left my clients without an easy way to remember the codes and parameters.
So I wrote a new Piklist parts/shortcodes file that just displays shortcode help. I may keep it around even after the shortcode interface is fixed. See https://github.com/donnamcmaster/mcpik-basics/tree/master/add-ons/mcpk-bas-shortcodes/parts/shortcodes for the details.
Attachments:
You must be logged in to view attached files. -
AuthorPosts