Displaying just a catagory to make a menu

7 posts by 2 authors in: Forums > CMS Builder
Last Post: February 28, 2008   (RSS)

Hello All,
I am sure I am over thinking this but what I would like is this. On the site I am building for an online coupon company, on the left will be a menu of the categories such as Restaurants,Travel,Car... ect. I want that to be generated by cms so say in the future they want more categories I don't need to mess with the template.

As it stands now the coupon section in cms it has all the information fields, upload fields, and a drop down category list. That list is what people can search and I would love to have cms build the menu on the left and have a category be clicked to show the search results.

One last question for now [;)] do they need to have admin rights to add items to the drop down list?

Thanks for all your help

Chris

Re: [ChrisTitchenal] Displaying just a catagory to make a menu

By Dave - February 26, 2008

Hi Chris,

Do you need subcategories? Those can be more challenging. And do you have a url that shows a menu like the one you want to create?

If you don't need sub categories, I'd just create two section: coupons and categories. In the coupon section have a list field that loads all the categories from the category section. Then have a list viewer that lists all the categories and links to the coupon viewer with a keyword search in the url. Like this: coupons.php?category=sports

LEt me know if that's what you need.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Displaying just a catagory to make a menu

Hi Dave, no thankfully I don't need sub categories. So what you are saying is go into the admin, Section Editors and add a new menu called category. In that menu make only a category drop down list, and use that to populate the list? Just checking to make sure that understand what you mean. My next question if I do that how can they preform the appropriate search to the matching categories. If I have
<?php echo $record['category'] ?> would I wrap it in something like <a href="coupons.php?category=['category']><?php echo $record['category'] ?></a>
I am sure that is wrong but I hope you get the the idea I am going for.


Thanks

Re: [ChrisTitchenal] Displaying just a catagory to make a menu

By Dave - February 27, 2008

Create a new menu called category with these fields: num, title

Go to the category menu and add a few records, one for each category.

Then in your coupon menu create a drop down list, select "Get options from database", select tablename "category", and "title" for option value and option label.

Then add a few coupons. You should have a pulldown list in the coupon menu with a list of all the categories from the category menu.

Then you'd create a list viewer to list all your categories and link each one to your coupon viewer like this:

<a href="coupons.php?category=<?php echo urlencode($record['category']) ?>><?php echo $record['category'] ?></a>

Hope that makes sense. Let me know if I can provide more detail.
Dave Edis - Senior Developer
interactivetools.com

Re: [ChrisTitchenal] Displaying just a catagory to make a menu

By Dave - February 28, 2008

Ahh, ok. I think I see the problem. If this is just listing the category table, and the category table only has fields num and title, we'll want to display title, not 'category' since that field doesn't exist.

Try replacing this: $record['category']

With this: $record['title']

Let me know if that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Displaying just a catagory to make a menu

I got it working thanks Dave, I even have it searching all 3 category fields.