Sections, categories and subcategories

9 posts by 4 authors in: Forums > CMS Builder
Last Post: January 26, 2010   (RSS)

By (Deleted User) - December 29, 2009

We have a website with different sections (information, products, resources, etc). Each SECTION is compounded by CATEGORIES and some CATEGORIES have SUBCATEGORIES.

How can we show at the List page (Section Home Page), only the CATEGORY? and then, when somebody clicks on the category link is linked to another list type page showing the SUBCATEGORIES? We are setting the Category as the Top Level Category and subcategories are being assigned to each category.

Today, despite of assigning to the Categories as "none, top level category" at the time of listing the content, we see everything, categories and subcategories.

is there a way to write a mySQL statement where parentCategory = none? for instance? Which is the value that we need to put to replace "none"? (or "not none" in case of showing the subcategory home page)?

Thank you,

Re: [rneube] Sections, categories and subcategories

By Chris - January 4, 2010

Hi rneube,

You can accomplish these requirements with getCategories(). Here is a list of the potential options you can use:

list($categoryRecords, $selectedCategory) = getCategories(array(
'tableName' => 'category', // REQUIRED
'rootCategoryNum' => '0', // Only categories _below_ this one will be shown (defaults to 0 for all)
'defaultCategory' => 'first', // Enter 'first', a category number, or leave blank '' for none
'ulAttributes' => " class='muList' ", // add html attributes to <ul> tags
'selectedCategoryNum' => '', // defaults to getNumberFromEndOfUrl()
'categoryFormat' => 'showall', // showall, onelevel, twolevel, breadcrumb
));


To list only the categories and not the subcategories, you'll want to set 'categoryFormat' => 'onelevel', 'rootCategoryNum' => '0'. When someone clicks on a category link, you'll want to use 'categoryFormat' => 'onelevel', 'rootCategoryNum' => $categoryNum -- where $categoryNum is the record number of the category clicked on.

Please post the full PHP source code for the page you're working on and I can help get it working how you'd like.

I hope this helps. If you have any questions, please let me know.
All the best,
Chris

Re: [rneube] Sections, categories and subcategories

By Chris - January 5, 2010

Hi rneube,

Does this code do what you want?

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php

require_once "/home/activefilings/public_html/cmsAdmin/lib/viewer_functions.php";

list($servicesRecords,) = getCategories(array(
'tableName' => 'services',
'loadUploads' => '0',
'selectedCategoryNum' => '', // defaults to getNumberFromEndOfUrl()
'categoryFormat' => 'onelevel',
));

?>

<!-- STEP2: Display Records (Paste this where you want your records to be listed) -->
<h1>Services - List Page Viewer</h1>
<?php foreach ($servicesRecords as $categoryRecord): ?>
<?php echo str_repeat("&nbsp; &nbsp; &nbsp;", $categoryRecord['depth']); ?>
<?php if ($categoryRecord['_isSelected']): ?><b><?php endif; ?>
<a href="?<?php echo $categoryRecord['num'] ?>"><?php echo $categoryRecord['name'] ?></a><br/>
<?php if ($categoryRecord['_isSelected']): ?></b><?php endif; ?>
<?php endforeach ?>
<!-- /STEP2: Display Records -->

All the best,
Chris

Re: [chris] Sections, categories and subcategories

By (Deleted User) - January 5, 2010

Hi Chris,

Thank you very much. It is very close to what I was looking for.

I would like to show the Name (title) and a litle abstract (headline). When somebody clicks on the title, instead of showing the subcategories at the same page, I would like to open a new page where the subcategories are showed in the same way (title, headline). Finally, if they click there, they could be showed the service page.

See what we have now, after having implemented your code:

http://www.activefilings.com/en/services/index.php

If you click on -for instance- Business Formation Services (1st choice), you expand the different services included in that category (basic inc service, full inc service, and so on). This list should be showed in a new page. The new page would link the service's name to the service page (which it cannot be displayed now).

Is that possible? Are we doing the right thing?

Thank you.

Re: [rneube] Sections, categories and subcategories

By (Deleted User) - January 6, 2010

We managed to correct the code and get a decent layout. Now, you can click on the individual items and you are linked to the service description page.

Thank you for your help!

Re: [rneube] Sections, categories and subcategories

By Donna - January 6, 2010

Glad to hear you got that sorted out. :) Let us know if you run into any other problems!
Donna

--
support@interactivetools.com

Re: [rneube] Sections, categories and subcategories

Hi Meube,

Could you share some of the details about how you finally ahieved your goal?

Best,

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] Sections, categories and subcategories

By (Deleted User) - January 26, 2010

We decided to hire the guys at InterativeTools and they did a great (and very affordable) job. I'm sorry but I wouldn't know what to share here. It was not only programming but also a good knowledge of the platform.