Right now, Im working on a set of tooltips (using Jquery library Qtip2) to trigger from a php array. Essentially the php array's items are generated from Wordpress, using a custom field manager. In this case, Wordpress can generate the array using an output filter.
The purpose? Having qtip load all cluetips which correspond to values given in this array (see attached image for a look at those values from the backend where they can be clicked on or off on whether they display on the front end or not. This is so that I can activate what product features are available for a particular custom item which we make) Based on what values come back for that product (i.e. what items are checked vs the ones that are not), I need each option that shows to have a hover action which will display a tooltip that has text/images which provide additional info on the option that they are mousing over.
If outputted raw I must put this in my php page:
- <?php print_custom_field('product_options'); ?>
If I set the output filter to "Set Default Value" I use this in the code:
- <?php print_custom_field('product_options:default', '<em>unknown</em>'); ?>
If I use a formatted list, than this is what I would have to use:
- <?php print_custom_field('product_options:formatted_list', array('<li>[+value+]</li>','<ul>[+content+]</ul>') ); ?><br />
I have mostly been looking towards outputting it as a to_array, as making the most sense. This is what I have come up with:
- $my_array = get_custom_field('product_options');
- $count = 1;
- foreach ($my_array as $item) {
- echo '<div>' ;
- print $item;
- echo '</div><div class="additinfo'.$count.'">Tooltip information</div>';
- $count++ ;
- }
- ?><br />
Simply put, I am not sure where I would set the conditional statements (if/then or case/switch or otherwise) that will display ONLY the tooltips which correspond to the values of that array which actually show up.
Any ideas if this process is before or after using JSON to pass it to jquery and issuing a selector (div ID/class more than likely)?