Hi, how I read the parameter "cat_params->showsearch" in following array:
QuoteArray (
[virtuemart_category_id] => 81
[category_parent_id] => 78
[virtuemart_vendor_id] => 1
[category_name] => Cozinhas e Churrasqueiras
[slug] => cozinhas-e-churrasqueiras-1
[cat_params] => show_store_desc=""|showcategory_desc=""|showcategory=""|categories_per_row=""|showproducts=""|omitLoaded=""|showsearch="0"|productsublayout=""|featured=""|featured_rows=""|omitLoaded_featured=""|discontinued=""|discontinued_rows=""|omitLoaded_discontinued=""|latest=""|latest_rows=""|omitLoaded_latest=""|topten=""|topten_rows=""|omitLoaded_topten=""|recent=""|recent_rows=""|omitLoaded_recent=""|
[limit_list_step] => 0
[limit_list_initial] => 0
)
I need "showsearch" value for show or not a classe in my template.
For example, the way "$this->product->category_name" work, but "$this->product->cat_params" do not.
Thanks
The parameters are json decoded
https://www.php.net/manual/en/function.json-decode.php (https://www.php.net/manual/en/function.json-decode.php)
Jörgen @ Kreativ Fotografi
Can you give me an example in this case?
Thanks again.
$cat_params = json_decode($this->product->cat_params);
Thanks for reply.
Quote from: GJC Web Design on June 02, 2020, 22:49:45 PM
$cat_params = json_decode($this->product->cat_params);
The return this is EMPTY. I tried json_decode($this->product->categoryItem[0]['cat_params']); but not worked.
With
Quoteprint_r($this->product->categoryItem[0]['cat_params']);
Show:
Quoteshow_store_desc=""|showcategory_desc=""|showcategory=""|categories_per_row=""|showproducts=""|omitLoaded=""|showsearch="0"|productsublayout=""|featured=""|
featured_rows=""|omitLoaded_featured=""|discontinued=""|discontinued_rows=""|omitLoaded_discontinued=""|latest=""|latest_rows=""|omitLoaded_latest=""|
topten=""|topten_rows=""|omitLoaded_topten=""|recent=""|recent_rows=""|omitLoaded_recent=""|
Thanks again
its not JSON
try explode("|", $this->product->categoryItem[0]['cat_params'])
Sorry, did not look close enough, John is right, exploding the data is the way to go.
Jörgen
The system is a little tricky.
It's not json, but if the parameter is not a string, then it's json encoded.
All this because the team do not wanted json in year 2012
Just leave it a string
$showsearch=0;
if (strpos($this->product->categoryItem[0]['cat_params'], 'showsearch="1"') !== false) {
echo 'hello';
$showsearch=1;
}
Quote from: GJC Web Design on June 03, 2020, 09:08:33 AM
its not JSON
try explode("|", $this->product->categoryItem[0]['cat_params'])
Yes, that's what I imagined. I was looking for a direct way to access the parameter, but it will have to be the traditional way, transforming it into an array. Thanks.
Quote from: PRO on June 03, 2020, 20:46:32 PM
Just leave it a string
$showsearch=0;
if (strpos($this->product->categoryItem[0]['cat_params'], 'showsearch="1"') !== false) {
echo 'hello';
$showsearch=1;
}
Also works.
Thanks.