Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import Variables from database #2

Open
ZainSohail opened this issue Aug 17, 2014 · 9 comments
Open

Import Variables from database #2

ZainSohail opened this issue Aug 17, 2014 · 9 comments

Comments

@ZainSohail
Copy link
Contributor

Okay, so I am not much of an expert when it comes to jQuery. So I though maybe someone could help me out a bit.

WHAT I AM TRYING TO DO:
I need to get these entries to the template, so that I could populate the graph.

Currently the graph is populate by variables which are acquired through QuantiModo API. I figured it out where it is initializing them but I couldn't find out how to use this var to use my database entries.

Used Here: https://github.com/Abolitionist-Project/QM-Personal-Studies-Plugin/blob/master/themefiles/js/bargraph_charts.js#L4

Initialized Here: https://github.com/Abolitionist-Project/QM-Personal-Studies-Plugin/blob/master/themefiles/js/libs/quantimodo-api.js#L137

I also tried to import the entries to a PHP function and then adding them to the 'variableName', but it didn't work. Here is what I tried ..

<?php 
global $wpdb;
$postid = $wpdb->get_results('SELECT post_id FROM qm_postmeta');
$metaid = $wpdb->get_results('SELECT meta_id FROM qm_postmeta');
$metakey = $wpdb->get_results('SELECT meta_key FROM qm_postmeta');
$metavalue = $wpdb->get_results('SELECT meta_value FROM qm_postmeta');
$currentpostid = get_the_ID();

if(!empty($metavalue)) {
      while($postid == $currentpostid){
        $metavalue = $variable['variableName'];
        return $variable;
      }
}
?>

@dinomov @mikepsinn

@mikepsinn
Copy link
Member

@QuintiModo @dinomov

  1. Which is the Examined Variable? Input or Output?
  2. Can we rename Input/Output to $examinedVariable and $secondaryVariable for clarity? Do you have any preferable naming suggestions?

@ZainSohail Are you able to get the variable name out of the database with that?

<?php 
global $wpdb;
$postid = $wpdb->get_results('SELECT post_id FROM qm_postmeta');
$metaid = $wpdb->get_results('SELECT meta_id FROM qm_postmeta');
$metakey = $wpdb->get_results('SELECT meta_key FROM qm_postmeta');
$metavalue = $wpdb->get_results('SELECT meta_value FROM qm_postmeta');
$currentpostid = get_the_ID();

if(!empty($metavalue)) {
      while($postid == $currentpostid){
        $metavalue = $variable['variableName'];
        return $variable;
      }
}
?>

You're setting $metavalue = $variable['variableName'], but where are you populating $variable?

In here: See: https://github.com/Abolitionist-Project/QM-Personal-Studies-Plugin/blob/master/themefiles/BarGraph.php#L125

Shouldn't you be populating the variable with a

$post_meta = get_post_meta($post->ID);
$examinedVariable = !empty($post_meta['examinedVariable'][0]) ? $post_meta['examinedVariable'][0] : NULL;

@dinomov @QuintiModo Could he then replace
<input type="hidden" id="selectBargraphInputVariable" value="" />
with
<input type="hidden" id="selectBargraphInputVariable" value=$examinedVariable />?

Should that work?

@mikepsinn
Copy link
Member

My confusion about the input/output variables is primarily based on the fact that this file

That seems to refer to the Examined Variable as the Output.

However, @dinomov said the Examined Variable is the Input.

@mikepsinn
Copy link
Member

This also indicates that the Examined Variable is the Output Variable.

screenclip

So I'm going to make an issue to change those. Please let me know if anyone has objections there.

@ZainSohail Were you able to get the page working normally without using the meta value to select the variable? That would be the first step. Then, if I'm not mistaken, you could try modifying the code in the Chrome Developer tools pane to see if my previous idea would work.

@ZainSohail
Copy link
Contributor Author

@mikepsinn

Are you able to get the variable name out of the database with that?

YES

You're setting $metavalue = $variable['variableName'], but where are you populating $variable?

What this step suppose to do is, extract variable name for the post id, and set them as 'variableName' so that it could be used in the graph.

  • $metavalue is the variable selected by the user
  • $variable['variableName'] is supposed to store the variable from $metavalue and use 'variableName' is jQquery as the selected variable.

Were you able to get the page working normally without using the meta value to select the variable? ..

Haven't checked that, need to install the api for that. Will try to do this today ..

@mikepsinn
Copy link
Member

Isn't the API already set up on zain-dev-wplms.quantimo.do? You can set up PHPStorm to work on that site directly. Let me know if you need help doing that.

There are tons of different types of meta values. Shouldn't that variable be named $examinedVariable instead of $metavalue?

There are also lots of different variables on the page listed on the bargraph. So you don't want to use the variable name $variable. You want to use $examinedVariable or something.

Shouldn't you be using the get_post_meta function?

Additionally you have return $variable;, but you don't have $variable = ... prior to that. What's up with that?

@ZainSohail
Copy link
Contributor Author

@mikepsinn

I made changes to my code, its working this way too

<?php 
$getvariable = get_post_meta( $post->ID, 'quantimodo_variables', true );
$getvariablecategory = get_post_meta( $post->ID, 'quantimodo_variable_category', true );

echo $getvariable;
echo $getvariablecategory;

?>

But I still can't make the graph use the variables which we are using in study metaboxes either than getting it from the QuantiModo API

@ZainSohail
Copy link
Contributor Author

@mikepsinn

About setting it up on zain-dev-wplms, just did that its not working for me because it can't detect any variables from my id in zain-dev-wplms. Please try if you have any variables added to your id.

Note: Settings in Metaboxe's won't work.

@mikepsinn
Copy link
Member

Can you log in with these?
user: quantimodo
pw: quantimodo

@ZainSohail
Copy link
Contributor Author

@mikepsinn

The id is not working ..

@joahnamarie26 joahnamarie26 added this to the Backlog milestone Aug 28, 2014
@joahnamarie26 joahnamarie26 removed this from the Backlog milestone Sep 1, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants