Sub-categories Tutorial

134 posts by 17 authors in: Forums > CMS Builder
Last Post: August 7, 2012   (RSS)

By Chris - June 8, 2010

Hi svsanchez,

I'm getting a 500 server error at www.casahermes.com/techos.php
All the best,
Chris

Re: [chris] Sub-categories Tutorial

By svsanchez - June 8, 2010

Hello Chris, sorry for that, there was a spike on the load of the server but it is working now!
Sven Sanchez

www.deguate.com

By Jason - June 9, 2010

Hi,

I took a look at this, and I think I found our error. We were only displaying a second column when a top level category was selected. As soon as you select a category from the second column, there is no longer a top level category that is selected. We can get around this by changing the variable ['isSelected'] to ['isSelectedBranch']. So our code to display our top level will look like this: (NOTE: I've highlighted the changes in red)

<?php $selectedCat=""; ?>
<?php foreach($categoryRecords as $category):?>
<?php if(!$category['_hasParent']):?>
<?php echo $category['_listItemStart']; ?>
<?php if($category['_isSelectedBranch']){echo "<b>"; $selectedCat=$category['num'];} ?>
<a href="?category=<?php echo $category['num']?>"><?php echo $category['name']; ?></a>
<?php if($category['_isSelectedBranch']){echo "</b>";} ?>
<?php echo $category['_listItemEnd']; ?>
<?php endif ?>
<?php endforeach ?>


That should be all that's required to fix this. Give it a try and let me know.

Thanks.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Sub-categories Tutorial

By svsanchez - June 9, 2010

Chris, as always thank you very much for your excellent support, this did the trick!
Sven Sanchez

www.deguate.com

By svsanchez - July 19, 2010

Hello Chris, how can I put in BOLD the selected SUB category in the code you sent me above?
Sven Sanchez

www.deguate.com

By Chris - July 19, 2010

Hi svsanchez,

Which code above are you referring to?
All the best,
Chris

Re: [chris] Sub-categories Tutorial

By svsanchez - July 19, 2010

Hello Chris I was referring to the one you previously posted:<?php $selectedCat=""; ?>
<?php foreach($categoryRecords as $category):?>
<?php if(!$category['_hasParent']):?>
<?php echo $category['_listItemStart']; ?>
<?php if($category['_isSelectedBranch']){echo "<b>"; $selectedCat=$category['num'];} ?>
<a href="?category=<?php echo $category['num']?>"><?php echo $category['name']; ?></a>
<?php if($category['_isSelectedBranch']){echo "</b>";} ?>
<?php echo $category['_listItemEnd']; ?>
<?php endif ?>
<?php endforeach ?>
Also regarding this code, it is not working on my single page display. Here's a link to both the list page and the single page:List page: www.casahermes.com/articulos.php (here it works)Details page: www.casahermes.com/articulos-details.php (here it doesn't work!)What do I have to change?
Sven Sanchez

www.deguate.com

By svsanchez - July 20, 2010

hello Chris, can you help me?
Sven Sanchez

www.deguate.com

By Jason - July 20, 2010

Hi,

There seems to be actual errors on your page for
http://www.casahermes.com/articulos-details.php

There are variables you are trying to use that you haven't initialized yet. If you can please attach this .php file, I can take a look at it for you.

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/