Sub-categories Tutorial

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

By Jason - July 21, 2010

Hi,

First, to get rid of the errors you're having on the page, on lines 123,124, and 125, replace the variable $record with $articlesRecord.

Next, if you want the links to go to articulo.php instead of the current detail page, change your links to this (I've highlighted the changes in red):

<a href="articulo.php?category=<?php echo $category['num']?>">

You'll need to make those changes in a few places. Give that a try and let me know if you run into any issues.

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/

By Jason - July 21, 2010

Hi,

Try changing the code to this (I've highlighted the changes in red):

<?php if($category['_isSelectedBranch'] || $category['_isSelected']){echo "<b>"; $selectedCat=$category['num'];} ?> <a href="articulos.php?category=<?php echo $category['num']?>"><?php echo $category['name']; ?></a> <?php if($category['_isSelectedBranch'] || $category['_isSelected']){echo "</b>";} ?>

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/

Re: [Jason] Sub-categories Tutorial

By svsanchez - July 22, 2010

Hi Jason, I tried your code but it didn't work, subcategories still don't appear in Bold. Here's what I wrote:

<?php $selectedCat=""; ?> <?php foreach($categoryRecords as $category):?> <?php if(!$category['_hasParent']):?> <?php if($category['_isSelectedBranch']|| $category['_isSelected']){echo "<b>"; $selectedCat=$category['num'];} ?> <a href="articulos.php?category=<?php echo $category['num']?>"><?php echo $category['name']; ?></a> <?php if($category['_isSelectedBranch']|| $category['_isSelected']){echo "</b>";} ?> <?php endif ?>
Sven Sanchez

www.deguate.com

By Jason - July 22, 2010

Hi,

Try this:

<?php $selectedCat=""; ?> <?php foreach($categoryRecords as $category):?> <?php if(!$category['_hasParent']):?> <?php if($category['_isSelectedBranch']|| @$_REQUEST['category']==$category['num']){echo "<b>"; $selectedCat=$category['num'];} ?> <a href="articulos.php?category=<?php echo $category['num']?>"><?php echo $category['name']; ?></a> <?php if($category['_isSelectedBranch']|| @$_REQUEST['category']==$category['num']){echo "</b>";} ?> <?php endif ?>
---------------------------------------------------
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 - July 22, 2010

Hi Jason, this code didn't work either, you can see it in www.casahermes.com/articulos.php choose from the categories menu to the left "TECHOS" and you will be presented with 3 subsections on the second column, chose the first one "FIBROCEMENTO" and it will be displayed BUT "FIBROCEMENTOS" will not be in Bold...
Sven Sanchez

www.deguate.com

By Jason - July 23, 2010

Hi,

If you could email CMS login and FTP details to jason@interactivetools.com I can take a closer look.

Please only email this information, don't post it to the forum.

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 - July 23, 2010

Hi Jason, email has been sent, thank you!
Sven Sanchez

www.deguate.com

By Jason - July 23, 2010

Hi,

I think we have it fixed. The code we were looking at previously was just to output the parent categories, not the sub categories. I changed the code that outputted the sub categories to this:

<?php if($selectedCat): ?>
<?php foreach($categoryRecords as $category): ?>

<?php if ($selectedCat==$category['parentNum']):?>
<?php if($category['_isSelected']){echo "<b>";}?>
<!--<?php echo $category['_listItemStart']; ?>--> <a href="?category=<?php echo $category['num']?>">
<?php echo $category['name']; ?> </a> <!--<?php echo $category['_listItemEnd']; ?>-->
<?php if($category['_isSelected']){echo "</b>";}?>
<?php endif ?> <p>
<?php endforeach ?>
<?php endif ?>


There was also a missing ":" on line 121 that I added in 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/

Re: [Jason] Sub-categories Tutorial

By svsanchez - July 23, 2010

Thank you Jason, that did it... now the only problem is the details page isn't showing the selected subcategory in bold:

http://www.casahermes.com/articulos-details.php?Ej-techos-fibrocemento-1
Sven Sanchez

www.deguate.com