More Category Menu Issues...

4 posts by 2 authors in: Forums > CMS Builder
Last Post: August 5, 2010   (RSS)

By whisper - August 5, 2010

I'm finally getting my feet wet with CMSB. I'm working on a backpage, and I've successfully gotten the respective category's articles to display (see http://www.bloxhamschool.com/cmsbabout.php?category=8)

However, I'm running into issues getting the categorymenu at left to behave properly. Ideally, only children of 'About Us' would display in orange on the left menu, with each child's articles being displayed when the menu is exploded. As the site currently sits, ALL categories and subcategories display at the left, and the selected category (currently Headline News)'s articles display/repeat under EVERY category.

Stuck here :(

Also, I'm a bit confused as to how I'll build the rest of the pages for the website. With AM2, I built only 1 categoryindex template, and used category variables to display the correct menus being highlighted, etc etc (eg the cms published the entire site from 1 or 2 templates). With CMSB, I feel like I have created cmsbabout.php, but I will need to create cmsbnews.php, cmsbadmissions.php, etc etc. Is this the case, or am I missing something?

Thanks in advance

Re: [Jason] More Category Menu Issues...

By whisper - August 5, 2010

Thanks Jason - I've gotten rid of the link pointing to ?category=

I've attached my template -can you point me in the right direction with

a) how to only have level 2 categories (subcategories) appear at left, and
b) how to have the selected category's articles display when the category is exploded?

Thanks in advance!!
Attachments:

cmsbabout.php 17K

Re: [whisper] More Category Menu Issues...

By Jason - August 5, 2010

Hi

So, are you looking that only categories that are a subcategory of the number in the url string be displayed along the left, and then only article records who's category is equal to one of the sub categories on the left, be displayed under that category?

Is that right?

If so, you can try this code (Note, this is untested, but should point you in the right direction):

<?php list($articlesRecords, $articlesMetaData) = getRecords(array(
'tableName' => 'articles',
));
?>

<?php foreach ($categoriesRecords as $categoryRecord): ?>
<div class="button-title"> <img src="/bloxtest/images/arrow-down.jpg" />

<?php if($category['parentNum']==@$_REQUEST['category']):?>
<?php if ($categoryRecord['_isSelected']): ?><b><?php endif ?>
<a href="#"><?php echo $categoryRecord['name'] ?></a>
<?php if ($categoryRecord['_isSelected']): ?></b><?php endif ?>

</div>
<div class="sub-links">
<div>
<ul>
<?php foreach ($articlesRecords as $record): ?>

<?php if($record['category']==$categoryRecord['num']):?>
<li> <a href="<?php echo $record['_link'] ?>"><?php echo $record['title'] ?></a></li>
<?php endif ?>

<?php endforeach ?>
</ul>
</div>
</div>
<?php endif ?>
<?php endforeach; ?>


Where it says $record['category'], you may have to replace 'category' with the name of the category field in your articles table.

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/