Forum Replies Created

Viewing 15 posts - 1 through 15 (of 125 total)
  • Author
    Posts
  • in reply to: Number type field is saved as Array #9439
    mcmaster
    Member

    Alex, 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)] );
    }
    
    in reply to: front-end form "action" parameter #9081
    mcmaster
    Member

    p.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.

    in reply to: File field only allows a single file #8847
    mcmaster
    Member

    My problem was resolved with the release of v 0.9.9.16.

    in reply to: File field only allows a single file #8817
    mcmaster
    Member

    FYI … 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).

    in reply to: File field only allows a single file #8816
    mcmaster
    Member

    I 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

    in reply to: Piklist Default 'field' Template – Grid Issue #8283
    mcmaster
    Member

    Glad it worked for you!

    in reply to: Piklist Default 'field' Template – Grid Issue #8280
    mcmaster
    Member

    Hi @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.
    mcmaster
    Member

    Hi, @ 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.

    mcmaster
    Member

    @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

    in reply to: Interested in Piklist #8277
    mcmaster
    Member

    Hi @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

    in reply to: Can't get form to work #8015
    mcmaster
    Member

    @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. 🙂

    in reply to: For those using 0.9.9.13 #8014
    mcmaster
    Member

    Thanks for clarifying; I was wondering why 0.9.9.13 wasn’t 0.10.x 😉

    in reply to: Why should I use the Piklist instead of the ACF? #7989
    mcmaster
    Member

    I 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.

    in reply to: Piklist next version ETA and changes? #7948
    mcmaster
    Member

    Thanks so much, Steve! I’m installing it on my WIP sites right now.

    Donna

    in reply to: editing problem with Piklist shortcodes #7935
    mcmaster
    Member

    Found 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.
Viewing 15 posts - 1 through 15 (of 125 total)