Forum
Passing category path into array problem
I need a variable passed into an array, however there's something I'm not doing right... little help please.
// Get the page level
perch_content_create('page-level', array(
'template' => 'product_level.html',
'multiple' => false,
'edit-mode' => 'listdetail',
));
// Save it as a var
$productLevel = perch_content_custom('page-level', array(
'template' => 'product_level_path.html',
'multiple' => false,
),true);
echo($productLevel);
if ($varCombninedCategories != NULL) {
array_push($varCombninedCategories, $productLevel);
} else {
$varCombninedCategories = array($productLevel);
}
print_r($varCombninedCategories);
$productLevel returns
category/seating-dining/
print_r($varCombninedCategories); returns
Array ( [0] => category/seating-dining/ )
Yet the below does not work:
perch_content_custom('Product-Items', array(
'template' => 'product_item_summary.html',
'page' => '/products/*',
'sort' => 'Product-Title',
'sort-order' => 'DESC',
'filter' => $filters,
'category' => $varCombninedCategories,
'category-match' => 'all',
'paginate' => true,
'count' => 24,
));
It only works if I use the below:
if ($varCombninedCategories != NULL) {
array_push($varCombninedCategories, 'category/seating-dining/');
} else {
$varCombninedCategories = array('category/seating-dining/');
}
However I need to use the variable passed into the array. Anybody know what I'm missing?
product_level.html
product_level_path.html
That should work - what does debug output?
*removed, no longer relevant.
It would be a really good idea to update Perch to the current version.
But then there's this issue: https://forum.grabaperch.com/forum/12-10-2015-perch-input-outputting-blank-select-option-incorrectly-as-bug
Anyway i did, and this thread's issue is still present.
That issue has been fixed.
Solved it, it was spaces " " in the variable.
Just used this to remove spaces: