• The $valueLabel array variable no longer seems to work in PHPCode since upgrading the plugin (not sure the exact version but think it was the one before last update..).

    The $valueLabel array should populate the labels for drop-down SELECT elements and was working fine on several post templates until the recent upgrade in question.

    Not sure if the variable name has been changed or if the feature is completely broken.

    Would be nice to know if anyone else is experiencing the same thing.

    Below is an example of code being used in the PHPCode section:

    $values = array();
    $valueLabel = array();
    $myPosts = get_posts('cat=22&numberposts=-1');
    foreach( $myPosts as $myPost )
    {
    $values[ count( $values ) ] = $myPost->ID;
    $valueLabel[ count( $valueLabel ) ] = get_post_meta( $myPost->ID, 'Venue Name', true ) . ', ' . get_post_meta( $myPost->ID, 'City', true );
    };
Viewing 5 replies - 1 through 5 (of 5 total)
  • I’m also struggling with this. Can’t see anything in the plugin code which leads me to understand where / why it isn’t working. Have yet to see where / how the php code replaces the standards inside the make_checkbox function starting on line 1623 of current version though.

    Thread Starter kiddhustle

    (@kiddhustle)

    Maybe it could be that some other plugin is conflicting with this one? I’m not sure I can have a look at the code and try to see if there is anything in other plugins/theme that might cause problem..

    Thread Starter kiddhustle

    (@kiddhustle)

    Oh, this is a SELECT element I’m generating not a CHECKBOX so I think make_select() is function involved (line: 1764)

    Thread Starter kiddhustle

    (@kiddhustle)

    Hi

    Just ran a quick test and I changed the label variable from $valueLabel to $valueLabels and the SELECT box worked as expected.

    I had a quick look at the code and in some places $valueLabel is used and some places $valueLabls is used. I guess $valueLabels makes more sense as a variable name but just need to make sure it’s the same for all field types and in the documentation.

    Could you let us know if we should definitely use valueLabels from now on?

    Cheers!

    Here’s a solution I worked up that doesn’t require any code change to the plugin which might help on all fronts until such time as a version update is released to solve. It puts the slug inside a javascript comment within the value so as not to show up on the front end. A little bit of work to parse it out for display included as well.

    Template
    [Client Organization]
    type=select
    code=2

    PHP Code in CFT #2`

    //Display Clients in Array
    global $wpdb;
    $clients = $wpdb->get_results
         ("SELECT post_title, post_name FROM $wpdb->posts where post_type = 'clients' and post_status = 'publish' order by post_title ASC");
    
    $clientCounter = 0;
    foreach ($clients as $client) {
    
    	$values[$clientCounter] = '<!-- //' . $client->post_name . ' -->' . $client->post_title;
    	$clientCounter++;
    }

    <strong>PHP Code in Template</strong>

    <?php
    							$client = get_post_meta($post->ID, 'Client Organization', false);
    							$client = split('-->',$client[0]);
    							$clientName = $client[1];
    							$clientSlug = split('<!-- //',$client[0]);
    
    							if ($PM) {
    								echo '<dt>Client Organization:</dt>';
    								$clientType = get_post_type_object('clients');
                           			echo '<dd><a href="/?' . $clientType->query_var . '=' . trim($clientSlug[1]) . '">' . $clientName . '</a></dd>';
    							}
    						?>

    Some of that could be wrapped into the template, shortcode, etc I have been working from creating data entry screens through to presentation and learning as I go with this plugin. While the functionality of it is awesome, the documentation and UI leaves a little bit to the art of discovery through trial and error or reading the code. However, the power if this proves to me how much WP core could benefit from having these types of capabilities. Especially if the same UI approach from the menus for drag & drop design were applied to it.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘$valueLabel no longer works in PHPCode’ is closed to new replies.