Categories and Subcategories

13 posts by 6 authors in: Forums > CMS Builder
Last Post: June 21, 2010   (RSS)

By Perchpole - March 27, 2009

Hi, Chassa -

There are a number of ways you can employ the method I outlined above. The simple method is pretty straight forward...

1) Create a new multi-page Editor. For the sake of argument we'll call it "Categories". The only data you need to enter for each record is the Title. So, create a couple of records, naming each one after a specific category (news, articles, features, etc...).

2) Next, create another multi-page editor called "Content". This will hold all of the articles on the site. Modify the editor according to your needs adding all the necessary fields you are likely to use.

3) Whilst working on this editor you will need to add a "List" field. Call it "Category". Use the "Get options from database" option and the select your "Categories" table (created in step 1) and then choose the "Title" for both the option and value selectors.

4) Now, when you come to add your first article you'll have a drop-down menu called "Category". This will allow you to assign the name of a category to each article you create.

5) All you need to do now is set-up your list pages so that CMS will display your articles according to the categories. The easiest/quickest way of doing this is to create a list index page for each of your categories. Then add the ''where ' code to the top of each page using the following format...

'where' => "category = 'YOURCATEGORY'",




You can also show multiple categories on the same page...

'where' => "category = 'YOURCATEGORY' OR category = 'ANOTHERCATEGORY'",




There is a slightly more dynamic way you can achieve the same results but this is a good way to start and get an understanding of the method in practice.

Also, if you take a look at the following website you'll be able to see how it works on a large portal.

http://www.theassaultgroup.co.uk/

Here each article is assigned to a category and each category is assigned to a section. It takes a bit of working out but it does work and really completely dynamic.

The take a look at the gallery section for an example of creating dynamic index pages on the fly...

http://www.theassaultgroup.co.uk/gallery/gallery_index.php

Use the menus beneath the thumbnails to select the content.

:0)

Perch

Re: [Perchpole] Categories and Subcategories

By studio-a - June 18, 2010 - edited: June 18, 2010

Hello,

We have been reading this thread and it has the content of information we are seeking, but it’s not been clarified. IF someone can fill in the missing pieces we sure would appreciate your help.

What’s missing are just a few elements from Dave and Perchole comments. For example, the comment Perchole made in his Step 5 using the code below appears as if we know the our category name (YOURCATEGORY). We thought the idea was to allow One Table to Dynamically populate the other Table’s particular field and then to list all the records in the second table accordly with the dynamically populated field. Are we reading the intentions for this thread correctly?

'where' => "category = 'YOURCATEGORY'",

The other information missing is the PHP code from Carrie so that’s a bit confusing too. Dave did bring to comment more code for the where statement, but how do we actually use it?

'where' => " parentCategory = '" .getNumberFromEndOfUrl() . "'",


BELOW IS OUR SETUP.

table 01 = service_categories
textfield within this table = category_name

table 02 = service_titles
droplist within this table = category (this is being dynamically populated from table 01 textfield category_name)
textfield within this table = service_title
textbox within this table = description

Our objective is to create List Pages for EACH Service Category while displaying the service_titles and descriptions associated with the dynamically created category_name(s) filtering.

Anyone who can help please do. We look forward to hearing from you.

Thanks for your time!

studio-a