Displaying just a catagory to make a menu
7 posts by 2 authors in: Forums > CMS Builder
Last Post: February 28, 2008 (RSS)
By Chris_t - February 26, 2008
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
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.
interactivetools.com
Re: [Dave] Displaying just a catagory to make a menu
By Chris_t - February 26, 2008
<?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
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.
interactivetools.com
Re: [Dave] Displaying just a catagory to make a menu
By Chris_t - February 28, 2008
<!-- STEP1: Load Record List (Paste this above other steps) -->
<?php
require_once "/home/clikq989/public_html/cmsAdmin/lib/viewer_functions.php";
$options = array(); // NOTE: see online documentation for more details on these
options
$options['tableName'] = 'category'; // (REQUIRED) MySQL tablename to list record from. Example:
'article';
$options['titleField'] = 'title'; // (optional) MySQL fieldname used in viewer url for search
engines. Example: 'title' would display: viewer.php/article_title_here-123
$options['viewerUrl'] = 'categoryPage.php'; // (optional) URL of viewer page. Example:
'/articles/view.php';
$options['perPage'] = ''; // (optional) The number of records to display per page.
Example: '5'; Defaults to 10.
$options['orderBy'] = 'title'; // (optional) Fieldnames to sort by. Example: 'field1,
field2 DESC, field3';
$options['pageNum'] = ''; // (optional) Page number of results to display. Example: '1';
Defaults to ?page=# value, or 1 if undefined
$options['where'] = ''; // (ADVANCED) Additional MySQL WHERE conditions. Example:
'fieldname = "value"'
$options['useSeoUrls'] = ''; // (ADVANCED) Set this to '1' for search engine friendly urls:
view.php/123 instead of view.php?123 (not supported on all web servers)
list($listRows, $listDetails) = getListRows($options);
?>
<!-- /STEP1: Load Record List -->
<!-- STEP2: Display Record List (Paste this where you want your records to be listed) -->
<?php foreach ($listRows as $record): ?>
<a href="couponsList.php?category=<?php echo urlencode($record['category']) ?>><?php echo
$record['category'] ?>"> </a><br/>
<?php endforeach ?>
<?php if ($listDetails['noRecordsFound']): ?>
No records were found!<br/>
<?php endif ?>
<?php if ($listDetails['invalidPageNum']): ?>
Results page '<?php echo $listDetails['page']?>' not found, <a href="<?php echo
$listDetails['firstPageLink'] ?>">start over >></a>.<br/>
<?php endif ?><br/>
<!-- /STEP2: Display Record List --><br/>
I had it fine displaying a list then when I try to make them link it shows blank ?
now the one thing that changed was we did that 3 categories per listing but I created that separate menu called category with just the title and number. I have a couponsList.php page and a couponsPage.php the menu I want to create will go on index.php
thanks for your help all the rest of your super advice works like a charm.
Chris T
Re: [ChrisTitchenal] Displaying just a catagory to make a menu
By Dave - February 28, 2008
Try replacing this: $record['category']
With this: $record['title']
Let me know if that helps!
interactivetools.com
Re: [Dave] Displaying just a catagory to make a menu
By Chris_t - February 28, 2008