Just not understanding how to set up Category menus

44 posts by 5 authors in: Forums > CMS Builder
Last Post: September 22, 2009   (RSS)

By Codee - August 12, 2009

Ross, Dave and Team...I've been reading the CMSB forum on this topic, in particular the threads at
http://www.interactivetools.com/iforum/Products_C2/CMS_Builder_F35/gforum.cgi?post=71850;search_string=category%20menu;t=search_engine#71850
and
Dave's original from last year at
http://www.interactivetools.com/forum/gforum.cgi?post=64259#64259

To be honest, I am lost on this. I've been trying to set up a test for doing the multilevel category thing and just am not "seeing" how to do it but I know what I want...it's simple:

I want to list the Manufacturers (category list) and when each manufacturer is chosen, I want it to list that manufacturers' models. Quick example:

Cheverolet
- Malibu
- AstroVan
- Citation

Chrysler
- Conquest
- Sebring
- Town and Country

Dodge
- Caravan
- Avenger
- Truck

If I could get a 1-2-3, a-b-c start for doing this I could probably fly on my own. The previously mentioned forum posts lost me.

Re: [chris] Just not understanding how to set up Category menus

By Codee - August 12, 2009

Chris,
THANK YOU for the simple 1-2-3! I will give it a go and report back.

Cheers!

Re: [equinox69] Just not understanding how to set up Category menus

By sublmnl - August 26, 2009 - edited: August 26, 2009

I think this is what we're looking for right now.
Did you get this to work?

Our client wanted a page that lists all projects
(not a list as we know it in code...)

Now they want Public and Private.
So my idea is to have a Navigation link to a 'list' 'page where they select Public or Private then see the (public or private) Project titles and a small icon and description next to it. Never both at the same time.

I think the above is the way to do it.
Although I do not need a click through to a detail page.
Just a list page for all items. (I could leave the link out of the php code and it wouldn't matter anyhow)

I was thinking this could be the answer....
?

(Edited)

One other thought I had is to use one page and pull in two records in a single page (can we do that?), but I want the client to be able to drag/sort them in the CMS, so I'm guessing we'd have to use a multirecord of some kind.

hopefully someone offer some advice.

Re: [sublmnl] Just not understanding how to set up Category menus

By Chris - August 27, 2009

Hi sublmnl,

If you're categorizing records into only two categories (Public and Private), and you don't expect to add more categories, it may be simpler to use a single Multi record section.

For example, I created a Multi record section called Projects and added a field called "access" of type "list", and entered these List Options:

Public
Private


Then I created some sample records, some Public, some Private. I generated list page viewer code, which listed all of my projects. I changed the code in STEP 1 to collect two lists of projects -- one for Public projects, one for Private projects:

list($publicProjectsRecords, $projectsMetaData) = getRecords(array(
'tableName' => 'projects',
'where' => 'access = "Public"'
));

list($privateProjectsRecords, $projectsMetaData) = getRecords(array(
'tableName' => 'projects',
'where' => 'access = "Private"'
));


I've attached the complete PHP list page for reference.

I hope this helps! Please let us know if you have any questions or comments.

P.S. Yes, you can load as many records (or record sets) into one page as you want.
All the best,
Chris
Attachments:

projectlist.php 3K

Re: [chris] Just not understanding how to set up Category menus

By sublmnl - August 30, 2009 - edited: August 30, 2009

thanks Chris.
I just got a chance to get back on this and I have an error:


MySQL Error: Unknown column 'access' in 'where clause'


I checked for case issues.
I am no php guru by any means. I'd say I'm somewhere in between a beginner and novice. I do appreciate your help also sorry to hijack the original thread but I think you are on to what we need.
Anyhow...

attached is the relevant portion of the code and the original generated code.
I create the field access list and changed the two options to public and private. Not sure whats up now.
Something else good may come of this too, you showed me the list 'thing' and now I have some other ideas for future clients. :)

Re: [sublmnl] Just not understanding how to set up Category menus

By Chris - August 30, 2009

Hi sublmnl,

I took a look at your code and noticed the following:

acccess: <?php echo $record['acccess'] ?>

It seems that your field is called "acccess" and mine is called "access". You'll either need to rename your field or change the where clauses to reflect your spelling.

Hope this helps! Please let us know if you have any more questions or comments.
All the best,
Chris

Re: [chris] Just not understanding how to set up Category menus

By sublmnl - August 31, 2009 - edited: August 31, 2009

holy type-o batman!
dang.

Must've been tired.
That did the trick.
I edited the cms and updated the spelling error in the php code.

Thanks Chris.

Now what if we had one more option?
Like expired or active?

Can we do the same thing and have two 'access' points to separate the lists into two more sections?

Re: [sublmnl] Just not understanding how to set up Category menus

By Chris - August 31, 2009

You certainly can! Let's say you called your new field "status". Then you'd want four getRecords() calls with each permutation of the possibilities:

list($publicActiveProjectsRecords, $projectsMetaData) = getRecords(array(
'tableName' => 'projects',
'where' => ' access = "Public" AND status = "Active" '
));
list($privateActiveProjectsRecords, $projectsMetaData) = getRecords(array(
'tableName' => 'projects',
'where' => ' access = "Private" AND status = "Active" '
));
list($publicExpiredProjectsRecords, $projectsMetaData) = getRecords(array(
'tableName' => 'projects',
'where' => ' access = "Public" AND status = "Expired" '
));
list($privateExpiredProjectsRecords, $projectsMetaData) = getRecords(array(
'tableName' => 'projects',
'where' => ' access = "Private" AND status = "Expired" '
));


(Advanced note: if you follow this approach much further and wind up with more than 10 getRecords() calls (and are having problems with page loading speed) it's possible to do the filtering in PHP -- but you'd lose simplicity and flexibility, so that should be a last resort.)

Hope this helps! Please let us know if you have any questions or comments.
All the best,
Chris

Re: [chris] Just not understanding how to set up Category menus

By sublmnl - August 31, 2009 - edited: August 31, 2009

awesome.
Works - now I need to format it and add some uploads.

Here is my code to share with the class:
(Keep in mind I did not want to use a detail page but you certainly can and add link and on the detail page have a summary section there to get full info... )

Head code:
list($publiccurrentprojectsRecords, $projectsMetaData) = getRecords(array(
'tableName' => 'all_projects',
'where' => 'access = "public" AND status = "current" '
));
list($publiccompletedprojectsRecords, $projectsMetaData) = getRecords(array(
'tableName' => 'all_projects',
'where' => 'access = "public" AND status = "completed" '
));

list($privatecurrentprojectsRecords, $projectsMetaData) = getRecords(array(
'tableName' => 'all_projects',
'where' => 'access = "private" AND status = "current" '
));
list($privatecompletedprojectsRecords, $projectsMetaData) = getRecords(array(
'tableName' => 'all_projects',
'where' => 'access = "private" AND status = "completed" '
));


body somewhere.... ;)

<p><strong>Current Public Jobs:</strong></p>
<?php foreach ($publiccurrentprojectsRecords as $record): ?>
<h4><?php echo $record['title'] ?></h4>
<p><?php echo $record['content'] ?></p>
<?php endforeach; ?>
<?php if (!$publiccurrentprojectsRecords): ?>
No current public projects were found!<br/><br/>
<?php endif ?>
<!-- next record -->

<p><strong>Completed Public Jobs:</strong></p>
<?php foreach ($publiccompletedprojectsRecords as $record): ?>
<h4><?php echo $record['title'] ?></h4>
<p><?php echo $record['content'] ?></p>
<hr/>
<?php endforeach; ?>
<?php if (!$publiccompletedprojectsRecords): ?>
No current public projects were found!<br/><br/>
<?php endif ?>
<!-- next record -->

<p><strong>Current Private Jobs:</strong></p>
<?php foreach ($privatecurrentprojectsRecords as $record): ?>
<h4><?php echo $record['title'] ?></h4>
<p><?php echo $record['content'] ?></p>
<?php endforeach; ?>
<?php if (!$privatecurrentprojectsRecords): ?>
No current private projects were found!<br/><br/>
<?php endif ?>
<!-- next record -->

<p><strong>Completed Private Jobs:</strong></p>
<?php foreach ($privatecompletedprojectsRecords as $record): ?>
<h4><?php echo $record['title'] ?></h4>
<p><?php echo $record['content'] ?></p>
<?php endforeach; ?>
<?php if (!$privatecompletedprojectsRecords): ?>
No current private projects were found!<br/><br/>
<?php endif ?>