how to get('main_div_name') from custom plugin

  • Posts: 50
  • Thank you received: 1
11 years 1 month ago #127838

Hi.

I am making a plugin triggerd by onBeforeProductListingLoad(). I need to get the 'main_div_name' value for some processing.
Eg I need to get the "hikashop_category_information_menu_xxx" or "hikashop_category_information_module_xx" value.

In the view, product listing_div it gets fetched by this:
$mainDivName=$this->params->get('main_div_name');

How to do that from the plugin? Can you please help me?

Regards

Mathias

Please Log in or Create an account to join the conversation.

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
11 years 1 month ago #127904

Hi,

The parameter "$view" in the trigger is the "$this" in your code sample.
Be careful. You have to check if you are in the front-end or in the backend.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 50
  • Thank you received: 1
11 years 1 month ago #127912

On the dev page the trigger is said to be:
onBeforeProductListingLoad(&$filters,&$order,&$parent, &$select, &$select2, &$a, &$b, &$on)

No $view paramenter. Or did I missunderstand?

/Mahias

Please Log in or Create an account to join the conversation.

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
11 years 1 month ago #127913

Hi,

I called it $view in my plugins, in the documentation the variable name is $parent, but it is the same thing, the "parent view" :)

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: matback

Please Log in or Create an account to join the conversation.

  • Posts: 50
  • Thank you received: 1
11 years 1 month ago #127920

Thanks Jerome.

I got it working now :)
It actually needs both $parent and $view.

Did like this:

function onBeforeProductListingLoad(&$filters, &$parent, &$view){
		 
$app =& JFactory::getApplication();
   if ($app->isAdmin()){
      return;
   }
   else {
       echo $view->params->get('main_div_name');   // TEST It works!
   }
}

It does not work with only $view or $parent. It needs to be both plus $filters. How come?

/Mathias

Please Log in or Create an account to join the conversation.

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
11 years 1 month ago #128003

Hi,

When in the doc it's called parent.

onBeforeProductListingLoad(&$filters,&$order,&$parent, &$select, &$select2, &$a, &$b, &$on)

I called it view.

onBeforeProductListingLoad(&$filters,&$order,&$view, &$select, &$select2, &$a, &$b, &$on)


But it's the same variable in the same position.
In your code, you "renamed" the $order into $parent. So $parent is not the parent, it's the order object...

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
Last edit: 11 years 1 month ago by Jerome.
The following user(s) said Thank You: matback

Please Log in or Create an account to join the conversation.

  • Posts: 50
  • Thank you received: 1
11 years 1 month ago #128019

Oh, I am so stupid ( after midnight brain stop) :woohoo: !!
Thanks for clarifying this too me Jerome.
Off course the parameter position is the thing and very important to get right in functions.

Just to make it "the right way." Now the code example is:

function onBeforeProductListingLoad(&$filters,&$order,&$view, &$select, &$select2, &$a, &$b, &$on){
		 
$app =& JFactory::getApplication();
   if ($app->isAdmin()){
      return;
   }
   else {
       echo $view->params->get('main_div_name');   // TEST It works!
   }
}


Once again many thanks Jerome.

Regards

Mathias

Last edit: 11 years 1 month ago by matback. Reason: Pasting error.

Please Log in or Create an account to join the conversation.

Time to create page: 0.064 seconds
Powered by Kunena Forum