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: [chris] Where or {continue} ?

By Perchpole - March 2, 2010

Hi, Chris -

Thanks for your note. The short answer is, Yes, it could work but I'd prefer to use a solution that could be applied, automatically, to every eventuality - rather than something that needs to be tailored to suit every instance.

I thought there would be a cunning way to use some of the preset arguments to arrive at a solution!

:0)

Perch

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