Forum

Thread tagged as: Question, Problem, Error

perch_categories() with skip-template

Hello,

I'm trying to implement a function that will run through all categories in a set called "topics" and check how many items in a given region are in each category. This demands that I initially store a list of the categories in the set as an array.

My code for achieving this first step is:

$categories = perch_categories(array(
  'set' => 'topics',
  'skip-template' => true,
));

And here's where it gets strange: even though skip-template is set to true, the line of code above prints the word "Array" to the page. Adding print_r($categories); adds nothing to the output. Moreover, the following code also only prints the word "Array", just as if the first and last lines were nonexistent.

$categories = "Test value";
$categories = perch_categories(array(
  'set' => 'topics',
  'skip-template' => true,
));
print_r($categories);

Running gettype($categories); after all this yields NULL. How can I make perch_categories() return an associative array that I can store as a variable?

Edit: I should probably mention that the same behavior occurs with perch_category():

$categories = perch_category('topics/example',array(
   'skip-template' => true,
));
Nicole Mirea

Nicole Mirea 2 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

I'll take a look at it.

Thank you!! Works great in latest update :)

Drew McLellan

Drew McLellan 2638 points
Perch Support

No problem!