News:

Looking for documentation? Take a look on our wiki

Main Menu

custom filters pro

Started by mblokdijk, September 05, 2016, 18:23:15 PM

Previous topic - Next topic

mblokdijk

i am using this, works great. but...

i need the result page to be assignable in the module, to i can use more templates, and assign template colors to more resultpages...

i went through the code, and in the renderhelper.php this shows:

   /**
    * Creates the href/URI for each filter's option
    *
    * @param stdClass $filter object
    * @param string $var_value the current the variable's value
    * @param string $type the type of url (option|clear)
    *
    * @author Sakis Terz
    * @return String URI
    * @since 1.0
    */
   private function getURL($filter, $var_value = NULL, $type = 'option')
   {
       $var_name = $filter['var_name'];
       $display_type = $filter['display'];
       $on_category_reset_others = false;

       if ($var_name == 'virtuemart_category_id') {
           $on_category_reset_others = $this->moduleparams->get('category_flt_onchange_reset', 'filters');
           if ($on_category_reset_others) {
               if (! empty($this->selected_flt_modif['virtuemart_category_id']))
                   $categ_array = $this->selected_flt_modif['virtuemart_category_id'];
               else
                   $categ_array = array();
           }
       }

       // in case of dependency top-bottom get the selected that this filter should use
       if ($this->moduleparams->get('dependency_direction', 't-b') == 't-b') {
           if (isset($this->selected_fl_per_flt[$var_name]))
               $q_array = $this->selected_fl_per_flt[$var_name];
           else
               $q_array = array();
       }

       // on category selection clear others
       else
           if ($on_category_reset_others) {
               $q_array['virtuemart_category_id'] = $categ_array;
               if ($on_category_reset_others == 'filters')
                   ! empty($this->selected_flt['q']) ? $q_array['q'] = $this->selected_flt['q'] : '';
           } else
               $q_array = $this->selected_flt_modif;

           // in case of category tree, the parent options are always links, no matter what is the display type of the filter
           if (! empty($filter['options'][$var_value]['isparent']))
               $display_type = 4;

           // do not include also the parents in the urls of the child
           if (! empty($filter['options'][$var_value]['cat_tree'])) {
               $parent_cat = explode('-', $filter['options'][$var_value]['cat_tree']);
               foreach ($parent_cat as $pcat) {
                   if (isset($q_array[$var_name])) {
                       $index = array_search($pcat, $q_array[$var_name]);
                       if ($index !== false) {
                           unset($q_array[$var_name][$index]);
                       }
                   }
               }
           }

           /*
            * in case of select , radio or links (single select) or is clear remove previous selected criteria from the same filter
            * only 1 option from that filter should be selected
            */
           if (($display_type != 3 && $display_type != 10 && $display_type != 12) || $type == 'clear') {

               //clear all the selections in all filters. e.g. search
               if($type == 'clear' && $filter['clearType']=='all')unset($q_array);

               //clear only the selections in that filter
               else unset($q_array[$var_name]);
           }

           /*
            * in case an option is already selected
            * The destination link of that option should omit it's value in case of checkboxes or multi-button
            * to create the uncheck effect
            */
           if (($display_type == 3 || $display_type == 10 || $display_type == 12) && (isset($q_array[$var_name]) && in_array($var_value, $q_array[$var_name]))) {
               if (is_array($q_array[$var_name])) {
                   $key = array_search($var_value, $q_array[$var_name]);
                   unset($q_array[$var_name][$key]);
                   $q_array[$var_name] = array_values($q_array[$var_name]); // reorder to fill null indexes
                   if (count($q_array[$var_name]) == 0)
                       unset($q_array[$var_name]); // if no any value unset it
               }
           }

           /* if not exist add it */
           else
               if ($var_value) {
                   if (isset($q_array[$var_name]) && is_array($q_array[$var_name])) {

                       // remove the null option which used only for sef reasons
                       if (isset($q_array[$var_name][0])) {
                           if ($q_array[$var_name][0] == '0' || $q_array[$var_name][0] == ' ') {
                               $q_array[$var_name][0] = $var_value;
                           }
                       }
                       $q_array[$var_name][] = $var_value;
                   } else
                       $q_array[$var_name] = array(
                           $var_value
                       );
               }

           /*
            * If the custom filters won't be displayed in the page in case a vm_cat and/or a vm_manuf is not selected
            * remove the custom filters from the query too
            */
           if ($var_name == 'virtuemart_category_id' || $var_name == 'virtuemart_manufacturer_id') {
               $cust_flt_disp_if = $this->moduleparams->get('custom_flt_disp_after');

               if (($cust_flt_disp_if == 'vm_cat' && $var_name == 'virtuemart_category_id') || ($cust_flt_disp_if == 'vm_manuf' && $var_name == 'virtuemart_manufacturer_id')) {
                   // if no category or manuf in the query
                   // remove all the custom filters from the query as the custom filters won't displayed
                   if (! isset($q_array[$var_name]) || count($q_array[$var_name]) == 0) {
                       $this->unsetCustomFilters($q_array);
                   }
               } else
                   if ($cust_flt_disp_if == 'vm_cat_or_vm_manuf' && ($var_name == 'virtuemart_category_id' || $var_name == 'virtuemart_manufacturer_id')) {
                       if (! isset($q_array['virtuemart_category_id']) && ! isset($q_array['virtuemart_manufacturer_id'])) {
                           $this->unsetCustomFilters($q_array);
                       }
                   } else
                       if ($cust_flt_disp_if == 'vm_cat_and_vm_manuf' && ($var_name == 'virtuemart_category_id' || $var_name == 'virtuemart_manufacturer_id')) {
                           if (! isset($q_array['virtuemart_category_id']) || ! isset($q_array['virtuemart_manufacturer_id'])) {
                               $this->unsetCustomFilters($q_array);
                           }
                       }
           }
         
           $itemId = $this->menu_params->get('cf_itemid', '');
         
           if ($itemId)
               $q_array['Itemid'] = $itemId;
           $q_array['option'] = 'com_customfilters';
           $q_array['view'] = 'products';

           // if trigger is on select load results
           // else load the module
           if ($this->results_trigger == 'btn') {
               unset($q_array['Itemid']);
               $q_array['module_id'] = $this->module->id;
           }

           $u = JFactory::getURI();
           $query = $u->buildQuery($q_array);
           $uri = 'index.php?' . $query;
           return $uri;
   }

see the red. that gets the menu id.

i added a field to my module, that i can use to get the id that i assigned in the module.

$Itemid=$params->get('module_id', '1286');

that shows the id that i setup in my module.


but changing the red for my code does not work... does any body have a solution?
Passionate Joomla webdeveloper from the Netherlands, please checkout jmodules.com