Multi tier product catalog

12 posts by 2 authors in: Forums > CMS Builder
Last Post: November 14, 2012   (RSS)

Re: [jacgo] Multi tier product catalog

By gregThomas - November 6, 2012

Hi,

The simplest solution to this is to create a category type section, and add all of the fields to it that you need for a product.

To do this go to the admin section, then go to the section editor menu. Click the Add new editor button, in the pop up box select the advanced menus radio button, and select Category menu as the menu type.

When you go to the section you will be able to easily create a tiered menu system.

The combo page creates a page that displays a single record from a section on the right, and menu of all of the records from that section on the left. This is probably the best code generator example for you to use, as it sounds like this is what your trying to achieve.

Let me know if you need more details on implementing this system.

Thanks!
Greg Thomas







PHP Programmer - interactivetools.com

Re: [greg] Multi tier product catalog

By jacgo - November 7, 2012

Hi Gerg
I use the Section Editors [Category Menu] to create the product section.
When I generat the code. I use the [Combo Page]

Got. [Record List] & [Record Detail]
Here is the page I created :
[url "http://174.132.79.189/~quanmax/embedded_boards_sbcs-list.php"]http://174.132.79.189/~quanmax/embedded_boards_sbcs-list.php[/#0066cc][/url]
[url "http://174.132.79.189/~quanmax/embedded_boards_sbcs-detail.php"]http://174.132.79.189/~quanmax/embedded_boards_sbcs-detail.php[/#0066cc][/url]

Above 2 pages are all the same.

There are three levels on my product page.
Parent Category
Sub Category
Detail Products

Do I need to Duplicate the combo code for 3 level page?
than only leave the correct code on the page.

sorry... a little bit confused.

Hope you can help.

Thanks!

Jac

Re: [jacgo] Multi tier product catalog

By gregThomas - November 7, 2012

Hi,

So you want to have 3 seperate page types for parent category, sub category and a details page? And each of these will contain dynamic information from the category section you created? Or are you trying to display all of this information on a single page?

If your trying to use three seperate pages, I would create three php files using the combo page, one for each level of your product page. As you are using a different page for each level you won't be able to use the current record list/navigation system on each page, I would replace it with something like this:

<b>Record List</b><br/>
<?php foreach ($shop_categoriesRecords as $listRecord): ?>
<?php $isSelected = ($listRecord['num'] == $detailRecord['num']); ?>
<?php if ($isSelected) { print "<b>"; } ?>
<a style="margin-left:<?php echo ($listRecord['depth']+1)*10; ?>px;" href="<?php if($listRecord['depth'] == '0'){
echo 'shop.php?num='.$listRecord['num'];
}elseif($listRecord['depth'] == '1'){
echo 'embedded_boards_sbcs-list.php?num='.$listRecord['num'];
}elseif($listRecord['depth'] == '2'){
echo 'embedded_boards_sbcs-detail.php?num='.$listRecord['num'];
}
?>" ><?php echo htmlencode($listRecord['name']) ?></a><br/>
<?php if ($isSelected) { print "</b>"; } ?>
<?php endforeach ?>

<?php if (!$shop_categoriesRecords): ?>
No records were found!<br/><br/>
<?php endif ?>


So this code changes the name of the file displayed in the navigation depending on the on if it is a parent category, sub category or details page, and it does this based on the pages depth. The ?num= part on the end of each url will ensure that the appropriate detail page information is loaded. You will need to modify the code so that it uses the page names and variable names you have created.

I hope I've made this clear, let me know if you have any questions or need any more help.

Thanks!
Greg Thomas







PHP Programmer - interactivetools.com

Re: [greg] Multi tier product catalog

By jacgo - November 8, 2012

Hi, Gerg

About your questoins:
Yes. I hope the product page can be 3 seperate page types for parent category, sub category and a details page.
And each of these will contain dynamic information from the category section you created.

but what I really want is to have is a no limit depth catalogs.

I hope my category look like:
http://www.quanmax.com/product/product_index.aspx
First level :
- Left sidebar : The first level catelog list.
- Right side : Same as the first level catelog list with the photo & short content.

Secand level :
- Left sidebar : The 1st level or 1,2 level catelog list
- Right side : the secand level category list.

Thired level (options):
- Left sidebar : The 1st level or 1,2,3 level catelog list
- Right side : the thired level category list.

Detail level :
- Left sidebar : The 1st level or full level lsit
- Right side : the detail product infromation.



I tried to study the article http://www.interactivetools.com/forum/gforum.cgi?do=post_view_flat;post=64259;page=1;sb=post_latest_reply;so=ASC;mh=25;
and created a page : http://www.ctrbs.org/categoryList.php

Also I follow your code the renew my test page
http://174.132.79.189/~quanmax/embedded_boards_sbcs-list1.php

Still don't know how to show the sub-category list the right side area.
My face is blue now.

Is there any real simple way to create the category on cmsAdmin directly?

Thanks!


Jacgo.

Re: [jacgo] Multi tier product catalog

By gregThomas - November 8, 2012

Hi Jacgo,

I understand what your trying to achive now, and I think I have a solution that should work.

The code you will need at the top of your page should look something like this:

// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('C:/wamp/www/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

// load detail record from 'shop_categories'
list($shop_categoriesRecords, $shop_categoriesMetaData) = getRecords(array(
'tableName' => 'shop_categories',
'where' => whereRecordNumberInUrl(1), // If no record # is specified then latest record is shown
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
));
$detailRecord = @$shop_categoriesRecords[0]; // get first record
if (!$detailRecord) { dieWith404("Record not found!"); } // show error message if no record found

// load list records from 'shop_categories'
list($leftMenu, $shop_categoriesMetaData) = getCategories(array(
'tableName' => 'shop_categories',
'loadUploads' => false,
'categoryFormat' => 'twolevel'
));

list($rightMenu, $shop_categoriesMetaData) = getCategories(array(
'tableName' => 'shop_categories',
'loadUploads' => false,
'rootCategoryNum' => $detailRecord['num'],
'categoryFormat' => 'onelevel'
));


You will need to change the variables names I have highlighted in red. So first we load the page details for the record that will appear in the details section of the page. Then the first getCategories function is used to create an array of all of the categories that appear in the the left hand menu. The categoryFormat array key I've highlighted in blue will need to be changed for the number of levels you want to display on each page. But it only accepts showall, onelevel, twolevel as variables.

The final getCategories function item will create the right hand menu array. The 'categoryFormat' array key will ensure that it only loads one level, and the 'rootCategoryNum' array key will ensure that only items below the currently loaded item will appear in the menu.



Then my html to display this looks like this:

<!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" />
<style type="text/css">
body { font-family: arial; }
.instructions { border: 3px solid #000; background-color: #EEE; padding: 10px; text-align: left; margin: 25px}
</style>
</head>
<body>

<!-- INSTRUCTIONS -->
<div class="instructions">
<b>Sample Combo Viewer - Instructions:</b>
<ol>
<?php ?>
<li><b>Remove any fields you don't want displayed.</b></li>
<li>Rearrange remaining fields to suit your needs.</li>
<li>Copy and paste code into previously designed page (or add design to this page).</li>
</ol>
</div>
<!-- /INSTRUCTIONS -->

<h1>Shop Categories - Combo Page Viewer</h1>

<table border="1" cellspacing="2" cellpadding="4">
<tr>
<td valign="top">

<!-- STEP2: Display Record List (Paste this where you want your record list) -->
<b>Record List</b><br/>
<?php foreach ($leftMenu as $listRecord): ?>
<?php $isSelected = ($listRecord['num'] == $detailRecord['num']); ?>
<?php if ($isSelected) { print "<b>"; } ?>
<a style="margin-left:<?php echo ($listRecord['depth']+1)*10; ?>px;" href="<?php if($listRecord['depth'] == '0'){
echo 'shop.php?num='.$listRecord['num'];
}elseif($listRecord['depth'] == '1'){
echo 'cat.php?num='.$listRecord['num'];
}elseif($listRecord['depth'] == '2'){
echo 'product.php?num='.$listRecord['num'];
}
?>" ><?php echo htmlencode($listRecord['name']) ?></a><br/>
<?php if ($isSelected) { print "</b>"; } ?>
<?php endforeach ?>

<?php if (!$shop_categoriesRecords): ?>
No records were found!<br/><br/>
<?php endif ?>
<!-- /STEP2: Display Record List -->

</td>
<td valign="top">

<!-- STEP2: Display Record Detail (Paste this where you want your record details) -->
<b>Record Detail</b><br/>

<?php foreach ($rightMenu as $listRecord): ?>
<?php $isSelected = ($listRecord['num'] == $detailRecord['num']); ?>
<?php if ($isSelected) { print "<b>"; } ?>
<a style="margin-left:<?php echo ($listRecord['depth']+1)*10; ?>px;" href="<?php if($listRecord['depth'] == '0'){
echo 'shop.php?num='.$listRecord['num'];
}elseif($listRecord['depth'] == '1'){
echo 'cat.php?num='.$listRecord['num'];
}elseif($listRecord['depth'] == '2'){
echo 'product.php?num='.$listRecord['num'];
}
?>" ><?php echo htmlencode($listRecord['name']) ?></a><br/>
<?php if ($isSelected) { print "</b>"; } ?>
<?php endforeach ?>


Record Number: <?php echo htmlencode($detailRecord['num']) ?><br/>
Parent Category: <?php echo htmlencode($detailRecord['parentNum']) ?><br/>
Name: <?php echo htmlencode($detailRecord['name']) ?><br/>
Content: <?php echo $detailRecord['content']; ?><br/>
_link : <a href="<?php echo $detailRecord['_link'] ?>"><?php echo $detailRecord['_link'] ?></a><br/>

<a href="mailto:?subject=<?php echo urlencode(thisPageUrl()) ?>">Email this Page</a>
<!-- /STEP2: Display Record Detail -->

</td>
</tr>
</table>

</body>
</html>


I would use something like this on your first, second and third level pages. This details page can probably kept in a similar format to what your currently using.

Thanks!
Greg Thomas







PHP Programmer - interactivetools.com

Re: [greg] Multi tier product catalog

By jacgo - November 9, 2012

Hi Greg

Thanks!

I tried to add image code below your code.


<a style="margin-left:<?php echo ($listRecord['depth']+1)*10; ?>px;" href="<?php if($listRecord['depth'] == '0')
{echo 'shop.php?num='.$listRecord['num'];}elseif($listRecord['depth'] == '1')
{echo 'cat.php?num='.$listRecord['num'];}elseif($listRecord['depth'] == '2')
{echo 'product.php?num='.$listRecord['num'];}?>"><?php echo htmlencode($listRecord['name']) ?> </a> <br/>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>

Each categories show same images
[url "http://174.132.79.189/~quanmax/embedded_boards_sbcs-combo.php"]http://174.132.79.189/~quanmax/embedded_boards_sbcs-combo.php[/#0066cc][/url]

Also when I click the left side menu items.
Got 404 errors.

My questions here is
1. How can I add
1) catelog image
2) catelog content
on right side columns?
2. Do I need to use Multi Record section or combo page to do the work ?
3. How can I difend php code without using php "foreach" ?

Hope you can help. Thanks again!

Jacgo

Re: [jacgo] Multi tier product catalog

By gregThomas - November 12, 2012

Hi Jacgo,

The reason your images are the same for each category is that the $upload variable isn't being set inside the foreach loop. You can access it in the foreach loop like this:

<img src="<?php echo $listRecord['nameOfUploadField][0][thumbUrlPath]; ?>" >

or:

<?php foreach($listRecord['nameOfUploadField'] as $picture): ?>
<img src="<?php echo $picture[thumbUrlPath]; ?>" >
<?php endforeach; ?>


Your getting 404 errors on some pages because they're linking to cat.php, which isn't a file you've created.

It doesn't matter if you use a multi record or combo page, both will contain any images you have uploaded as long as you have loadUploads set to true in your getRecords/getCategories function:

list($categoryRecords, $categoryMetaData) = getRecords(array(
'tableName' => 'category',
'where' => "`num` = '1'",
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
));


A combo page is a combination of both a details page and a list page. It will display all of the records from the section on the left, and carry out a page search in the right hand column.

Could you give me a bit more detail on point 3?

Thanks!
Greg Thomas







PHP Programmer - interactivetools.com

Re: [greg] Multi tier product catalog

By jacgo - November 13, 2012

Hi Greg
One of my friend help me to figure it out.
My friend add some code below your code.
Here is the code for reference.


<?php foreach ($rightMenu as $listRecord): ?>
<?php $isSelected = ($listRecord['num'] == $detailRecord['num']); ?>
<?php if ($isSelected) { print "<b>"; } ?>
<a style="margin-left:<?php echo ($listRecord['depth']+1)*10; ?>px;" href="<?php if($listRecord['depth'] == '0')
{echo 'shop.php?num='.$listRecord['num'];}elseif($listRecord['depth'] == '1')
{echo 'cat.php?num='.$listRecord['num'];}elseif($listRecord['depth'] == '2')
{echo 'product.php?num='.$listRecord['num'];}?>"><?php echo htmlencode($listRecord['name']) ?> </a> <br/>

<?php
echo "num# ". $listRecord['num']. "<br/>";
list($ahd, $bhd) = getRecords(array(
'tableName' => 'embedded_boards_sbcs',
'where'=> " num='". $listRecord['num']. "'",
'loadUploads' => true,
'allowSearch' => false,
'limit'=> 1,
));

[url "mailto:$atm=@$ahd[0"]$atm=@$ahd[0[/url]];
$xpic=$atm['image'][0];

if ($xpic) {
echo "<img src='". $xpic['thumbUrlPath']. "' width='". $xpic['thumbWidth']. "' height='". $xpic['thumbHeight']. "'/><br/>";
}
?>



--------------------------------------------------------------------------------------
I just wonding to know is there any simple way to show same level images?

Just hope the code simple to handle.

Thanks!

Jacgo.

Re: [greg] Multi tier product catalog

By jacgo - November 14, 2012

Hi Greg

I think I found the article.

http://www.interactivetools.com/forum/gforum.cgi?post=77230

It is real simple and fit my need.