sub categories on detail page

19 posts by 3 authors in: Forums > CMS Builder
Last Post: March 10, 2009   (RSS)

Hi,
I have created a category menu with subs, works fine but what I would like to do is find a way to display the sub category links on the detail page of the top level category. I hope this is clear and possible because right now I am sort of hard coding those sub category links through a wysiwyg text box in cmsb(not really be best solution).

Re: [Dan Maitland] sub categories on detail page

By Dave - February 23, 2009

Hi Dan,

The code generator doesn't create code for category sections yet but you can find an example attached to the first post on this thread:
http://www.interactivetools.com/iforum/P64259

However, if you're only dealing with two or three levels sometimes it's simpler to create 2 or 3 sections instead. What type of content are you working with? Do you have an example url?
Dave Edis - Senior Developer
interactivetools.com

Re: [Dan Maitland] sub categories on detail page

By Dave - February 23, 2009

Ok, no problem. Do you just want the categories that are directly below the selected record?
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] sub categories on detail page

Exactly!

Re: [Dave] sub categories on detail page

So Dave do you have a mini solution for me on this?

Re: [Dan Maitland] sub categories on detail page

By Dave - February 24, 2009

I do, there's a few ways to do it. Category section have a field called 'parentNum' that lists the record number of their parent.

So the first step is getting the record number of the current record. You may have that in a variable such as $record['num'] so you can use that or the following line:

$num = $record['num'];

or

$num = getNumberFromEndOfUrl();

Then generate some list viewer code and add a where of "num = '$num'" like this:

list($categoryRecords, $categoryMetaData) = getRecords(array(
'tableName' => 'category',
'where' => " num = '$num' ",
));


And that will list only the "child" record of the current record.

Hope that makes sense. Let me know if that works for you.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] sub categories on detail page

Sorry for the delayed response. I will give your method a try but do I have to worry about anything getting messed up with the category menu I already have on that page?

Also on that same note: Is there a way to display the category menu in my websites second language because right now it is using the english titles and I need to be able to display the french titles for that same menu in the french section?

Re: [Dan Maitland] sub categories on detail page

By Dave - February 26, 2009

You can give the variable a different name so it doesn't conflict with existing code on the page. Such as:

list($subCategoryRecords, $categoryMetaData) = getRecords(array(
'tableName' => 'category',
'where' => " num = '$num' ",
));


As for displaying a seperate language. Do you already have fields or records setup with translated content or are you just starting with multi language?
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] sub categories on detail page

Yes the French fields are already set up the.