categories question

11 posts by 2 authors in: Forums > CMS Builder
Last Post: February 17, 2010   (RSS)

If i have something like this:

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

and i show var_dump($selectedCategory);

i get one record, and i can access its data.

But if i have:

list($categoryRecords, $selectedCategory) = getCategories(array(
'tableName' => 'category',
'selectedCategoryNum' => 'field',
));

and i show var_dump($selectedCategory);

i get an empty array

array(0) { }

Why this behaviour? im just filtering by 'field' and i should get some info.

How to handle this?

Re: [flamerz] categories question

By Chris - February 10, 2010

Hi flamerz,

selectedCategoryNum is meant to accept a number, not a field name.

What exactly is it you're trying to accomplish?
All the best,
Chris

Re: [flamerz] categories question

just want to filter by fieldnum when I have pagination too.

code works fine but I wish to access to selectedcategory variable

Re: [flamerz] categories question

Ill try to explain me better.

list($categoryRecords, $selectedCategory) = getCategories(array(
'tableName' => 'category',
'selectedCategoryNum' => 'subcat',
));

I have a list like before. Categories are selected succefully.

When i choose a category by url looks like:
http://localhost/test/companies.php?subcat=8

if i dont add the selectedCategoryNum line, when i use pagination:
http://localhost/test/companies.php?page=2

this get category like "2".

My main problem is that i have some check in code:

<?php if ( isset($selectedCategory['breadcrumb'])): ?>
<?php echo $selectedCategory['breadcrumb']; ?><?php endif ?>

to show the breadcrumb in the top of website.

If i add the 'selectedCategoryNum' => 'subcat', parameter, pagination works fine... but i lost the $selectedCategory variable.

Re: [flamerz] categories question

By Chris - February 11, 2010

Hi flamerz,

Can you please post the full PHP source code for your page?
All the best,
Chris

Re: [chris] categories question

yes.. here it is.

i attach the schemas and database.

Re: [flamerz] categories question

By Chris - February 12, 2010

Hi flamerz,

Thanks! Attaching your schema and database files made it very easy for me to research this problem for you! :)

The latest version of CMS Builder automatically preserves extra query string arguments when generating paging links (which is what you're trying to do.)

What version of CMS Builder are you using?
All the best,
Chris

Re: [chris] categories question

Im using 2.01, but i think i can update if needed.

Still playing on localhost.

Re: [chris] categories question

Thanks, i sent the info already.