Okay
  Public Ticket #1543638
using placeholders with charts
Open

Comments

  • danbarejr started the conversation

    I'm trying to use the placeholders (i.e., var1) with a chart.

    The chart is based on a table (wpdatatable) that uses var1, but when I try a shortcode of [wpdatachart id=1 var1=22] the var1 doesn't work.  The var1 only uses the default in the table definition.

    Is there something I'm not doing right?

    Thanks - Dan 

  •  351
    Bogdan replied

    Hi Dan,
    Thank you for your purchase.

    Sorry to disappoint you but unfortunately using placeholders with charts are not possible with the plugin built in features at the moment.

    Best regards.

    Never miss notifications about new cool features, promotions, giveaways or freebies - subscribe to our newsletter! Join 2000+ subscribers. We send about one mail per month and never spam!

    Kind Regards,
    Bogdan Radusinovic
    bogdan@touchmesoft.net

  • danbarejr replied

    I have an easy work-around for this you should check out.

    This code could be modified in a number of ways.

    1) I pass variables on the url, as in www.example.com/?var1=33&var2=123

    2) I register the variables in my theme functions.php by adding this:

    function add_query_vars_filter( $vars ){
      $vars[] = "var1";
      $vars[] = "var2";
      $vars[] = "var3";
      return $vars;
    }
    add_filter( 'query_vars', 'add_query_vars_filter' );

    3) I add a plugin for shortcode as:

    <?php
    /*
    Plugin Name: wpsetvars
    Description: Custom vars in URL to Global vars
    Version: 0.1
    Author: Daniel Bare
    Text Domain: wpsetvars
    */

    function wpsetvars_func($params) {
    global $wdtVar1, $wdtVar2, $wdtVar3;
    if (get_query_var(var1')) {
    $var1 = get_query_var('var1'); // get var1 from url line
    //*** $params['var1']  -- could scrape from shortcode instead
    $wdtVar1 = $var1;
    }
    if (get_query_var('var2')) {
    $var2 = get_query_var('var2'); 
    //*** $params['var2']
    set_query_var('var2', $var2);
    $wdtVar2 = $var2;
    }
    if (get_query_var('var3')) {
    $var3 = get_query_var('var3'); 
    //*** $params['var3'] 
    $wdtVar3 = $var3;
    }
    return;
    }

    add_shortcode( 'wpsetvars', 'wpsetvars_func' );

    ?>

    4) Activate Shortcode wpsetvars

    5) in page - note - wpdatachart is based on a table that uses var1 

    [wpsetvars][wpdatachart id=1]

    6) use url www.example.com/?var1=3  

    depending on what is var1 in in the url, the chart changes

    done.

    -------------

    I suspect this would be easy to implement into the wpdatacharts, as it's so easy to do this.

    I haven't tested this with wpdatatables, but it might work as well - to put the vars on the URL as well.

  •  351
    Bogdan replied

    Hi Dan,

    Thank you for your feedback and suggestion. 
    I will forward this to my team and also this ticket is public so the other users can see it in case they want to implement something similar.

    Thank you again.

    Best regards.

    Never miss notifications about new cool features, promotions, giveaways or freebies - subscribe to our newsletter! Join 2000+ subscribers. We send about one mail per month and never spam!

    Kind Regards,
    Bogdan Radusinovic
    bogdan@touchmesoft.net