categories question

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

By flamerz - February 10, 2010

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

By flamerz - February 10, 2010

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

By flamerz - February 11, 2010

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

By flamerz - February 12, 2010

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

By flamerz - February 12, 2010

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

Still playing on localhost.

Re: [flamerz] categories question

By Chris - February 15, 2010

Hi flamerz,

Hmm, I just scoured the changes and that feature hasn't been added since 2.01. I'm stumped as to why it's not working for you.

When I tried to reproduce your problem earlier it simply worked for me, which is why I thought you might be running an old version of the software.

Do you have a website where it's not working which I could have FTP access to? I could do a little research and figure out why it's not working, then fix it for you.

If so, please fill out a second level support ticket at http://www.interactivetools.com/support/ . Please write in the ticket comments "for chris" and a link to this forum thread. :)

I hope to get this fixed for you in short order.
All the best,
Chris