AbanteCart Community

AbanteCart Development => Development Help Needed => Topic started by: dhigz on October 11, 2016, 03:59:06 PM

Title: Get viewport $args value (func_get_args) in hook
Post by: dhigz 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
Title: Re: Get viewport $args value (func_get_args) in hook
Post by: abolabo 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
Title: Re: Get viewport $args value (func_get_args) in hook
Post by: dhigz on October 13, 2016, 08:39:54 PM
Got it to work with suggestion #2. Thanks again for your help.