From: Anthony Talarico Date: Tue, 11 Apr 2017 18:07:25 +0000 (-0400) Subject: adding ajax action for search filtering between brands and manufacturers X-Git-Tag: v1.0.0^2~37 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=cc7e7c70746f9ff20e56ad5c730d928b83a07dc8;p=WP-Plugins%2Fglm-member-db-fields.git adding ajax action for search filtering between brands and manufacturers no logic yet, test content commented out currently. --- diff --git a/models/admin/ajax/filterSearch.php b/models/admin/ajax/filterSearch.php new file mode 100644 index 0000000..18fb75a --- /dev/null +++ b/models/admin/ajax/filterSearch.php @@ -0,0 +1,119 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @version 0.1 + */ + +// Load Event Times data abstract +require_once GLM_MEMBERS_PLUGIN_CLASS_PATH .'/data/dataCategories.php'; + + +/* + * This class performs the work of handling images passed to it via + * an AJAX call that goes through the WorPress AJAX Handler. + * + */ +class GlmMembersAdmin_ajax_filterSearch extends GlmDataCategories +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + + /* + * Constructor + * + * This contructor sets up this model. At this time that only includes + * storing away the WordPress data object. + * + * @return object Class object + * + */ + public function __construct ($wpdb, $config) + { + + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + // Run constructor for members data class + parent::__construct(false, false); + + } + /** + * getModelEventsData + * + * Return the array of events. + * + * @param integer $categoryId Id of the category for filtering events (optional) + * @param integer $limit Number of events to return (optional) + * @param integer $memberID Member ID if filtering by member + * + * @access public + * @return array events + */ + + + /* + * Perform Model Action + * + * This modelAction takes an AJAX image upload and stores the image in the + * media/images directory of the plugin. + * + * This model action does not return, it simply does it's work then calls die(); + * + * @param $actionData + * + * Echos JSON string as response and does not return + */ + public function modelAction ($actionData = false) + { + + global $wpdb; +// +// $category_ids = $_REQUEST['cat_ids']; +// $category_names = $_REQUEST['cat_names']; +// +// // get cat ids by name +// foreach($category_names as $cat_name){ +// $sql = 'SELECT id FROM ' . GLM_MEMBERS_PLUGIN_DB_PREFIX . "categories WHERE name = '$cat_name';"; +// $cat_id = $wpdb->get_var($sql); +// +// // get the +// } +// +// +// $categories = $this->getListSortedParentChild(); +// $categories = $categories[$category_id]; + $return = array( +// 'manufacturers' => $category_ids, +// 'brands' => $cat_id + ); + + header('Content-type:application/json;charset=utf-8', true); + echo json_encode($return); + wp_die(); + } +} diff --git a/setup/validActions.php b/setup/validActions.php index 5e68202..33ebbae 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -62,6 +62,9 @@ $glmMembersFieldsAddOnValidActions = array( 'memberinfo' => array( 'fields' => GLM_MEMBERS_FIELDS_PLUGIN_SLUG, ), + 'ajax' => array( + 'filterSearch' => GLM_MEMBERS_FIELDS_PLUGIN_SLUG, + ), 'management' => array( 'fields' => GLM_MEMBERS_FIELDS_PLUGIN_SLUG, ), diff --git a/views/front/fields/list.html b/views/front/fields/list.html index e617edf..083107b 100644 --- a/views/front/fields/list.html +++ b/views/front/fields/list.html @@ -1,6 +1,5 @@ {foreach $field_values as $key=>$value} {if $value.slash === true} -
{else}