Where or {continue} ?

6 posts by 2 authors in: Forums > CMS Builder
Last Post: March 2, 2010   (RSS)

By Perchpole - March 1, 2010

Hello, All -

Although I don't have much php experience I think I'm canny enough to work out most things to fulfil a particular requirement. In recent days, however,I've encountered a number of issues where my usual clumsy approach would benefit from a bit of finesse!

Here's a typical example...

Parent Category
- Child 1
- Child 2
- Child 3

I need to show all the items of a parent category and its child categories in one list. I think I can do this in either of two ways...

First by using a "where" argument - to list only those articles found in the parent and/or child categories.

Second, by use of a {continue} construct in the list's foreach loop - to filter out unwanted entries.

Could someone please show me a neat way of doing this?

Thanks

Perch

Re: [Perchpole] Where or {continue} ?

By Chris - March 2, 2010

Hi Perchpole,

Can this be solved with "rootCategoryNum"?

$numOfParentCategory = 123;

list($categoryRecords, $selectedCategory) = getCategories(array(
'tableName' => 'category',
'rootCategoryNum' => $numOfParentCategory,
));


Does that help? Please let me know if you have any questions.
All the best,
Chris

Re: [Perchpole] Where or {continue} ?

By Chris - March 2, 2010

Hi Perch,

We can generalize the above solution if we can figure out the "num" of the parent category to display.

How does the page that's displaying this list of categories know which parent category it wants to display? Is the num passed in the query string or do you need to search some fields to determine which category?

If you can give me a specific example of how you want this to work, I can show you how to generalize it.
All the best,
Chris

Re: [chris] Where or {continue} ?

By Perchpole - March 2, 2010

Hi, Chris -

The number would come direct from the category num - which presumably would be at the end of the URL.

:o)

Perch

Re: [Perchpole] Where or {continue} ?

By Chris - March 2, 2010

Hi Perch,

Does this solve the problem then?

$numOfParentCategory = getNumberFromEndOfUrl();

list($categoryRecords, $selectedCategory) = getCategories(array(
'tableName' => 'category',
'rootCategoryNum' => $numOfParentCategory,
));


Please let me know if you have any questions.
All the best,
Chris