Displaying just a catagory to make a menu

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

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: [Dave] Displaying just a catagory to make a menu

Hey Dave this one is being a bit tricky

<!-- 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 &gt;&gt;</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

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.