Sub-categories Tutorial

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

By cjpritchard - May 15, 2012

Hi Jason,

This doesn't seem to work. The faq_categories selector inside the FAQ editor is actually a checkbox (ref: attachment faq_editor.jpg above). Does that make a difference?

Thanks,
Chris

Re: [cjpritchard] Sub-categories Tutorial

By robin - May 15, 2012

Hey Chris,

Using a checkbox list will store the information the same way in the database so it's no problem.

In the section editor for faqs, could you click modify on faq_categories and post what the pop-up looks like? If we can see what your list options looks like we can better see what's not working with your code.

Thanks,
Robin
Robin
Programmer
interactivetools.com

Re: [robin] Sub-categories Tutorial

By cjpritchard - May 15, 2012

Hi Robin,

Attached is a screenshot of that part of the editor.

Thanks,
Chris

Re: [cjpritchard] Sub-categories Tutorial

By Jason - May 16, 2012

Hi Chris,

I spotted a typo in my code that would explain why it's not working.

Try this:

<?php foreach ($faq_categoriesRecords as $categoryRecord): ?>

<h1><?php echo $categoryRecord['category_name'] ?></h1>
<?php $faqsRecords = mysql_select("faqs", "faq_categories LIKE '%\t".intval($categoryRecord['num'])."\t%'"); ?>

<?php foreach($faqsRecords as $record): ?>

<h2><?php echo $record['question'] ?></h2>
<p><?php echo $record['content'] ?></p>

<?php endforeach ?>

<?php endforeach ?>


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 cjpritchard - May 16, 2012

Thanks Jason,

That works great. Appreciate the help.

Chris

Re: [Chris] Sub-categories Tutorial

By cmsb - August 6, 2012

Hi, I did this (but changed the names of my categories and articles to something for meaningful for my site), but it's not working.[shocked]

Here's the url of the list page: http://www.mtgrovecemetery.org/articlesList.php?category=1

Shouldn't something be happening when I click on one of the links? For instance, shouldn't the list at least change?

Many Thanks!

By cmsb - August 6, 2012

Hi Jason, I suspect you are asking for code for detail pages? Is that it? I only used the code generator to make that one page -- the one you have the url for. I did not make any other pages. I looked for but did not find a prompt in the tutorial to make detail pages -- is that the step I'm missing?[unsure]

Re: [cmsb] Sub-categories Tutorial

By Jason - August 7, 2012

Hi,

What's happening is that your articles list is not being filtered. Are you using 'allowSearch' => false, in your articles getRecords() call? If so, try removing that.

If not, how are articles associated with categories? Do you have a list field call category in your articles section?

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/

By cmsb - August 7, 2012

Hi Jason, Thanks for all your help. [:)] Here's the code for my articlesList.php:

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php


// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/usr/home/mtgrov/www/htdocs/','','../','../../','../../../');
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 records from 'articles'
list($categoriesRecords, $selectedCategory) = getCategories(array( 'tableName' => 'categories', ));
list($articlesRecords, $articlesMetaData) = getRecords(array(
'tableName' => 'articles',
'loadUploads' => true,
'allowSearch' => false,
));

?><!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">
<title>Mountain Grove Cemetery - Bulletin Board</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<meta name="keywords" content="Mountain Grove Cemetery Association, Bridgeport, Fairfield County, Connecticut, cremated remains, cemetery, crematory, cremation, crematorium, columbarium niches, urn gardens, memorialize" />
<meta name="description" content="Mountain grove has one of the finest Crematoriums in the state offers its own chapel and three cremation chambers. Additionally, Mountain Grove offers a wide choice of where to place cremated remains." />
<LINK HREF="mgc.css" REL="stylesheet" TYPE="text/css">
<!-- Add jQuery library -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script type="text/javascript" src="../fancybox/lib/jquery.mousewheel-3.0.6.pack.js"></script>
<script type="text/javascript" src="../fancybox/source/jquery.fancybox.js"></script>
<script type="text/javascript" src="../fancybox/source/jquery.fancybox.pack.js"></script>
<link href="../fancybox/source/jquery.fancybox.css" rel="stylesheet" type="text/css" />
<link href="../fancybox/source/helpers/jquery.fancybox-buttons.css" rel="stylesheet" type="text/css" />
<link href="../fancybox/source/helpers/jquery.fancybox-thumbs.css" rel="stylesheet" type="text/css" />
<link href="../jquery/screen.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../jquery/custom.js"></script>
<script type="text/javascript" src="../fancybox/source/helpers/jquery.fancybox-buttons.js"></script>
<script type="text/javascript" src="../fancybox/source/helpers/jquery.fancybox-media.js"></script>
<script type="text/javascript" src="../fancybox/source/helpers/jquery.fancybox-thumbs.js"></script>

<!-- Add fancyBox -->
<script type="text/javascript">
$(document).ready(function() {
$(".fancybox").fancybox();
});
</script>
</head>
<body>





<h1><span style="font-size: 21px; font-family:'Times New Roman', Times, serif">Categories</span></h1>
<ul>
<li><a href="?">(All Articles)</a></li>
<?php foreach ($categoriesRecords as $categoryRecord): ?>
<?php echo $categoryRecord['_listItemStart'] ?>
<?php if ($categoryRecord['_isSelected']): ?><b><?php endif ?>
<a href="?category=<?php echo $categoryRecord['num'] ?>"><?php echo $categoryRecord['name'] ?></a>
<?php if ($categoryRecord['_isSelected']): ?></b><?php endif ?>
<?php echo $categoryRecord['_listItemEnd'] ?>
<?php endforeach ?>
</ul>

<h1><span style="font-size: 21px; font-family:'Times New Roman', Times, serif">Articles - List Page Viewer</span></h1>
<?php foreach ($articlesRecords as $record): ?>
<a href="<?php echo $record['_link'] ?>"><?php echo $record['title'] ?></a><br/>
<?php endforeach ?>

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



</body>
</html>