News:

Looking for documentation? Take a look on our wiki

Main Menu

[SOLVED] Read Category Parameters

Started by henry_osn, June 02, 2020, 00:40:57 AM

Previous topic - Next topic

henry_osn

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

Jörgen

Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

henry_osn

Can you give me an example in this case?
Thanks again.

GJC Web Design

$cat_params = json_decode($this->product->cat_params);
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

henry_osn

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

GJC Web Design

its not JSON

try explode("|", $this->product->categoryItem[0]['cat_params'])
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Jörgen

Sorry, did not look close enough, John is right, exploding the data is the way to go.

Jörgen
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

Studio 42

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

PRO

Just leave it a string

$showsearch=0;
if (strpos($this->product->categoryItem[0]['cat_params'], 'showsearch="1"') !== false) {
    echo 'hello';
$showsearch=1;
}

henry_osn

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.

henry_osn

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.