Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

Display Module for VMF component filter results

Display Module for VMF component filter results

I found this code, which works well.

Code:

if (

  $option == 'com_vmfiltering'
  and $view == 'Vmf'
  and JRequest::getVar('task') == 'search' ) {

    $allcats = array( 2, 14, 90, 91, 92, 93, 94, 15, 95, 96, 97, 16, 98, 99, 100, 17, 101, 102, 103, 18);

    $vm_cat = JRequest::getVar('vm_cat');
    $vm_man = JRequest::getVar('vm_mnuf');
    if ( is_array( $vm_cat ) ) {
      foreach ($vm_cat as $cat ) {
        if ( in_array( $cat, $allcats ) )  return 75;
      }
    }
    // check for manufacturers
    if ( is_array($vm_man) and count($vm_man) > 0 ) return 75;
}

But I do not know how I would adjust it so that I can show for each category a different module (regardless of manufacturer, and features) and for selected 2 or more different modules.

Is it possible to do?

svito
Beginner Modder
ranks
useravatar
Offline
3 Posts
Administrator has disabled public posting

Re: Display Module for VMF component filter results

Hi svito,

I'm not 100% sure what you are asking for when you say "and for selected 2 or more different modules". Can you please explain that more?

If you simply want to be able to assign different modules to different categories, you could do it this way:


if (
  $option == 'com_vmfiltering'
  and $view == 'Vmf'
  and JRequest::getVar('task') == 'search' ) {

    $allcats = array(
2=>101,
14=>102,
90=>"103,104",  // example of returning more than one
91=>75,
92=>75,
93=>75,
94=>75,
15=>75,
95=>75,
96=>75,
97=>75,
16=>75,
98=>75,
99=>75,
100=>75,
17=>75,
101=>75,
102=>75,
103=>75,
18=>75
);

    $vm_cat = JRequest::getVar('vm_cat');
    $vm_man = JRequest::getVar('vm_mnuf');
    if ( is_array( $vm_cat ) ) {
      foreach ($vm_cat as $cat ) {
        if ( array_key_exists( (int)$cat, $allcats ) )  return $allcats[(int)$cat];
      }
    }
    // check for manufacturers
    if ( is_array($vm_man) and count($vm_man) > 0 ) return 75;
}


Cheers,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3328 Posts
User info in posts
Administrator has disabled public posting

Re: Display Module for VMF component filter results

Hi,
just to clarify my query.

Source code attached works well. What I need is: In case of selection all, none, 2 or more categories I need to be able to define which module to display.

Thanx a lot.

svito
Beginner Modder
ranks
useravatar
Offline
3 Posts
Administrator has disabled public posting

Re: Display Module for VMF component filter results

I attached examples links.

Example of selecting 2 or more (up to all) categories:

Code:

http://www.domian.net/index.php?option=com_vmfiltering&task=search&vm_cat[]=15&vm_cat[]=35&vm_cat[]=48&vm_cat[]=72&feat_fl[]=4

Example when no category is selected:

Code:

http://www.domian.net/index.php?option=com_vmfiltering&task=search&feat_fl[]=4&feat_fl[]=5

svito
Beginner Modder
ranks
useravatar
Offline
3 Posts
Administrator has disabled public posting

Re: Display Module for VMF component filter results

Oh, I see what you mean.

So if you just want to base the module selection on how many categories were selected, you would do this:

Code:

if ( 

  $option == 'com_vmfiltering'
  and $view == 'Vmf'
  and JRequest::getVar('task') == 'search' ) {
    $vm_cat = JRequest::getVar('vm_cat');
    if ( $vm_cat == null or !is_array( $vm_cat ) ) return AAA; // no categories selected
    if ( count($vm_cat) == 1 ) return BBB; // 1 category selected
    if ( count($vm_cat) >= 2 ) return CCC; // 2+ categories selected
}

I don't know how many categories you have in total, so you'll need to check for the exact number in order to detect if they are all selected. You should be able to easily adapt the code above in order to do that.

Now, combining the 2 sets of PHP in order to do the following:

1 - if a manufacturer is selected
2 - if no categories are selected
3 - if all categories are selected
4 - if 2 or more (but not all) categories are selected
5 - if just 1 is selected, choose the module based on a list.

Code:

if ( 

  $option == 'com_vmfiltering'
  and $view == 'Vmf'
  and JRequest::getVar('task') == 'search' ) {

    $allcats = array(
      2=>101,
      14=>102,
      90=>"103,104",  // example of returning more than one
      91=>75,
      92=>75,
      93=>75,
      94=>75,
      15=>75,
      95=>75,
      96=>75,
      97=>75,
      16=>75,
      98=>75,
      99=>75,
      100=>75,
      17=>75,
      101=>75,
      102=>75,
      103=>75,
      18=>75
    );

    $vm_cat = JRequest::getVar('vm_cat');
    $vm_man = JRequest::getVar('vm_mnuf');

    // 1 - check for manufacturers
    if ( is_array($vm_man) and count($vm_man) > 0 ) return 75;

    // 2 - if no categories are selected
    if ( $vm_cat == null or !is_array( $vm_cat ) ) return AAA; // no categories selected

    // 3 - if all categories are selected
    $c = count($vm_cat);
    if ( $c == 100 ) return BBB; // all categories selected (change 100 to the tot num of cats)

    // 4 - if 2 or more categories are selected
    if ( $c >= 2 ) return CCC; // 2+ categories selected

    // 5 - if only 1 category selected, choose module from array above according to cat.
    foreach ($vm_cat as $cat ) {
      if ( array_key_exists( (int)$cat, $allcats ) )  return $allcats[(int)$cat];
    }
}

Replace AAA, BBB, CCC with module ids to use in each case.

The one issue you might have here is that because the manufacturer is checked BEFORE the categories, you might always get the "manufacturer" module instead of the category ones. So you could put the manufacturer check last... except that you have already checked for 0 or more categories, so it will never get to the manufacturer check. So do you still need the manufacturer check? Perhaps not, and you could remove those lines.

Cheers,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3328 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1679
Total Polls:
6
Total Posts:
5933
Total Posts Today:
2
User Info:
 
Total Users:
4371
Newest User:
kajha63871
Members Online:
0
Guests Online:
188

Online: 
There are no members online

Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked