Creating a side menu with categories of products
12 posts by 2 authors in: Forums > CMS Builder
Last Post: August 25, 2010 (RSS)
By fsardoni - August 24, 2010
I have built it following some directions from this forum but I am having problems with the following error:
Warning: Cannot modify header information - headers already sent by (output started at /home/content/g/o/f/gofgof/html/productsList.php:29) in /home/content/g/o/f/gofgof/html/includes/productnavigation.php on line 1
Can someone please help me or just point me to the right thread in this forum?
Many thanks in advance.
Re: [fsardoni] Creating a side menu with categories of products
By fsardoni - August 24, 2010
<?php header('Content-type: text/html; charset=utf-8'); ?>
of the navigation fixed it.
Re: [fsardoni] Creating a side menu with categories of products
By fsardoni - August 24, 2010
Re: [fsardoni] Creating a side menu with categories of products
By Chris - August 24, 2010
Can you provide more information on the problem? A link to your page, a description of what you're getting vs. what you expect, and an attachment of your full PHP source code would be very helpful. :)
Chris
Re: [chris] Creating a side menu with categories of products
By fsardoni - August 24, 2010 - edited: August 24, 2010
The link is: http://www.greetingsoffaith.com/productsList.php
Please find all my files attached.
I am also having this issue where the products are displaying a number instead of the category name... It's a mess. Sorry and thank you.
PS.forgive the look it is not css stylized yet.
Re: [fsardoni] Creating a side menu with categories of products
By Chris - August 24, 2010
Since you named your category field "categories", any URLs will need to reflect this. Here's a URL that seems to work:
[url http://www.greetingsoffaith.com/productsList.php?categories=All%20Occasions%20:%20Birthday]http://www.greetingsoffaith.com/productsList.php?categories=All%20Occasions%20:%20Birthday[/url]
That said, you're probably going to want to use nums for categories. (Use this field for option values: num)
Have you checked out the [url http://www.interactivetools.com/iforum/Products_C2/CMS_Builder_F35/Sub-categories_Tutorial_P77230/]Sub-categories Tutorial[/url]?
I hope this helps! Please let me know if you have any questions.
Chris
Re: [chris] Creating a side menu with categories of products
By fsardoni - August 25, 2010
Thank you.
Yes I did check the Sub-categories Tutorial, infact some of the code is lifted from there.
Re: [fsardoni] Creating a side menu with categories of products
By fsardoni - August 25, 2010
http://www.greetingsoffaith.com/productDetail.php?category=32
instead of showing me or bringing me back to:
http://www.greetingsoffaith.com/productsList.php?category=32:
Why is that? and Or should it be that way?
Thank you
Re: [fsardoni] Creating a side menu with categories of products
By Chris - August 25, 2010 - edited: August 25, 2010
You're getting all the records because category=32 is ignored by CMS Builder since there is no field called "category".
Your other issue is also caused by the URLs: they're relative to the current document since they start with "?". You'll want to explicitly link to /productsList.php.
You can change the URLs by modifying this line in productnavigation.php:
<a href="?category=<?php echo $categoryRecord['num'] ?>"><?php echo $categoryRecord['name'] ?></a>
...to:
<a href="/productsList.php?categories=<?php echo $categoryRecord['num'] ?>"><?php echo $categoryRecord['name'] ?></a>
I hope this helps! Please let me know if you have any questions.
Chris
Re: [chris] Creating a side menu with categories of products
By fsardoni - August 25, 2010
Notice: Undefined variable: categoryRecord in /home/content/g/o/f/gofgof/html/includes/productnavigation.php on line 27 (All Products)
<?php
// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/home/content/g/o/f/gofgof/html/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }
list($categoriesRecords, $selectedCategory) = getCategories(array(
'tableName' => 'categories',
));
list($productsRecords, $productsMetaData) = getRecords(array(
'tableName' => 'products',
));
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
</head>
<body>
<ul>
<li><a href="/productsList.php?categories=<?php echo $categoryRecord['num'] ?>"><?php echo $categoryRecord['name'] ?>(All Products)</a></li>
<?php foreach ($categoriesRecords as $categoryRecord): ?>
<?php echo $categoryRecord['_listItemStart'] ?>
<?php if ($categoryRecord['_isSelected']): ?><b><?php endif ?>
<a href="/productsList.php?categories=<?php echo $categoryRecord['num'] ?>"><?php echo $categoryRecord['name'] ?></a>
<?php if ($categoryRecord['_isSelected']): ?></b><?php endif ?>
<?php echo $categoryRecord['_listItemEnd'] ?>
<?php endforeach ?>
</ul>
</body>
</html>