Showing content that meets certain criteria

5 posts by 3 authors in: Forums > CMS Builder
Last Post: February 25, 2011   (RSS)

By NigelGordijk - February 24, 2011

I have a single section of CMSB that is broken down into several categories; e.g. Sports, Places of Worship, and Schools. I'd like to display all of the content on a single page, but shown under the appropriate headings. I can get all of the content to show under each heading, but I don't know how to only display the sport content under Sports, the places of worship under Places of Worship, etc.

http://www.wilmot.ca/links-websites.php

This is the code that displays the content:

<?php foreach ($community_linksRecords as $record): ?>
<p><strong><a href="<?php echo $record['content'] ?>"><?php echo $record['title'] ?></a></strong></p>
<?php endforeach ?>
<?php if (!$community_linksRecords): ?>
<?php endif ?>

This is repeated under every subheading on the page.

Any ideas how to show the appropriate content in the right place, please?
Nigel Gordijk

Common Sense Design: User-focused Web design
Tel: 001 519 342 5348 | Web: www.commonsensedesign.net
Attachments:

links-websites.php 14K

Re: [Toledoh] Showing content that meets certain criteria

By NigelGordijk - February 25, 2011

Hi, Tim.

There is a category dropdown menu for my client to choose which section the record belongs in. These are words, not numbers:

Sports
Places of Worship
Schools
Libraries
Community Groups
Newspapers
Tourism

Will your system only work with numbers?
Nigel Gordijk

Common Sense Design: User-focused Web design
Tel: 001 519 342 5348 | Web: www.commonsensedesign.net

Re: [NigelGordijk] Showing content that meets certain criteria

By Jason - February 25, 2011

Hi Nigel,

That code should still work for you, just don't add the +0 in the orderBy clause,

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] Showing content that meets certain criteria

By NigelGordijk - February 25, 2011 - edited: February 25, 2011

Perfect! Thank you both, gentlemen!

I'd like to have the headings duplicated at the top with anchored links to the relevant section on the page. I've been able duplicate the headings at the top of the page - http://www.wilmot.ca/links-websites.php - but I don't know how to create the anchored links.

This is the code that creates the line of headings at the top:

<?php $lastCategory = ''; ?>
<?php foreach ($community_linksRecords as $record): ?>
<?php if ($lastCategory != $record['category']): ?>
<?php echo $record['category:label'] ?>&nbsp;&nbsp;&nbsp;
<?php endif; ?>
<?php $lastCategory = $record['category']; ?>
<?php endforeach ?>

And this is the code - adapted from Tim - that displays the various sections beneath:

<?php $lastCategory = ''; ?>
<?php foreach ($community_linksRecords as $record): ?>
<?php if ($lastCategory != $record['category']): ?>
<h3 CLASS="h3RuleAbove"><?php echo $record['category:label'] ?></h3>
<?php endif; ?>
<p><strong><a href="<?php echo $record['content'] ?>" target="_blank"><?php echo $record['title'] ?></a></strong></p>
<?php $lastCategory = $record['category']; ?>
<?php endforeach ?>

Any suggestions, please?
Nigel Gordijk

Common Sense Design: User-focused Web design
Tel: 001 519 342 5348 | Web: www.commonsensedesign.net