Author Topic: Get viewport $args value (func_get_args) in hook  (Read 4824 times)

Offline dhigz

  • Newbie
  • *
  • Posts: 45
  • Karma: +16/-0
    • View Profile
Get viewport $args value (func_get_args) in hook
« on: October 11, 2016, 03:59:06 PM »
I am working on an extension that uses the new "Quick View" option. Everything is working great but I need to filter out a description field in quick view mode. The problem is I cannot get the viewport_mode value in func_get_args() in my hook function. The hook function does process  func_get_args() and I can get other value pairs, just not the viewport_mode/value pair.

I tried calling func_get_args() an InitData hook for the page, but get same result (or lack there of). Same result if called in an UpdateData hook.

The only way I could get it to work is to add $this->data['viewport_mode'] = $viewport_mode; to the base file.

Do you have any suggestions on what I can do so I do not have to edit the base file?

Thanks
Don Higbee

Offline abolabo

  • core-developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2046
  • Karma: +318/-13
  • web for all, all for web!
    • View Profile
    • AbanteCart
Re: Get viewport $args value (func_get_args) in hook
« Reply #1 on: October 12, 2016, 11:00:29 AM »
You have two ways:
1. use UpdateData hook but get viewport_mode value from view. for ex
$viewport_mode = $this->baseObject->view->getData('viewport_mode');
Then just rewrite with emptyness some data in view
$this->baseObject->view->assign('vsome_description_var', '');
2. hook to controller admin/controller/responses/common/viewport.php and set inside InitData some sign about viewport. for ex. $this->baseobject->registry->set('your_viewport_mode', 'your value');
Then use it inside another hook
“No one is useless in this world who lightens the burdens of another.”
― Charles Dickens

Offline dhigz

  • Newbie
  • *
  • Posts: 45
  • Karma: +16/-0
    • View Profile
Re: Get viewport $args value (func_get_args) in hook
« Reply #2 on: October 13, 2016, 08:39:54 PM »
Got it to work with suggestion #2. Thanks again for your help.
Don Higbee

 

Powered by SMFPacks Social Login Mod