AbanteCart Development > Development Help Needed
How to correctly add hook to $this->getHookVar('product_description_array')
(1/1)
yonghan79:
Hi core devs,
I'm found this hook "$this->getHookVar('product_description_array')" in the product.tpl file.
I have tried to add array like this:
--- Code: ---$tabs['Test'] = [
'title' => $view->fetch('pages/test/test_tab.tpl'),
'html' => $view->fetch('pages/test/test_content.tpl')
];
$that->view->addHookVar('product_description_array',$tabs);
--- End code ---
It's not working.
I tried to debug in the tpl file and found out that the variable is set as a string contains 'array', not a real array.
abolabo:
hook var's value must be a string, not array.
Different extensions can add it's values and we use concatenation for that
yonghan79:
This is what is in products.tpl file:
--- Code: ---$hookVarArray = $this->getHookVar('product_description_array');
if( $hookVarArray ){
foreach($hookVarArray as $key=>$hkVar){ ?>
<div class="accordion-item">
<h2 class="accordion-header" id="heading<?php echo $key; ?>>">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapse<?php echo $key; ?>"
aria-expanded="true" aria-controls="collapse<?php echo $key; ?>">
<?php echo $hkVar['title']; ?>
</button>
</h2>
<div id="collapse<?php echo $key; ?>" class="accordion-collapse collapse" aria-labelledby="heading<?php echo $key; ?>" data-bs-parent="#productDetailsAccordion">
<div class="accordion-body">
<?php echo $hkVar['html']; ?>
</div>
</div>
</div>
--- End code ---
abolabo:
$hookVarArray is a string, not array!
abolabo:
if you want to pass an array use $that->view->assign('your_tpl_variable_name', $someArray); inside your hook file where $that = $this->baseObject; (controller instance)
Navigation
[0] Message Index
Go to full version