Organizing Lists

13 posts by 2 authors in: Forums > CMS Builder
Last Post: February 8, 2010   (RSS)

Sorry.. here's everything...

TOP OF PAGE:
<?php

require_once "\\\\frigga/home/users/web/b302/as.pequannock/admin/lib/viewer_functions.php";

list($policies0000Records, $policies0000MetaData) = getRecords(array(
'tableName' => 'policies',
'allowSearch' => '0',
'where' => "section = '0000 - Bylaws'",
));

?>
<?php

require_once "\\\\frigga/home/users/web/b302/as.pequannock/admin/lib/viewer_functions.php";

list($policies1000Records, $policies1000MetaData) = getRecords(array(
'tableName' => 'policies',
'allowSearch' => '0',
'where' => "section = '1000 - Administration'",
));

?>

BODY OF PAGE:
<p class="policyheader">0000 - Bylaws</p>
<?php foreach ($policies0000Records as $record): ?>
<p><?php foreach ($record['document'] as $upload): ?><a href="<?php echo $upload['urlPath'] ?>"><?php echo $record['policy_number'] ?> - <?php echo $record['policy_title'] ?></a><?php endforeach ?></p><?php endforeach ?>

<p class="policyheader">1000 - Administration</p>
<?php foreach ($policies1000Records as $record): ?>
<p><?php foreach ($record['document'] as $upload): ?><a href="<?php echo $upload['urlPath'] ?>"><?php echo $record['policy_number'] ?> - <?php echo $record['policy_title'] ?></a><?php endforeach ?></p><?php endforeach ?>

Can be viewed at:
http://www.pequannock.org/district/board-of-education/policies.php
John Tedesco

Creative Director



JAM Graphics

Re: [jtedescojam] Organizing Lists

By Chris - February 8, 2010

Hi jtedescojam,

This page is a lot more complicated to rewrite to have automatic column headings. In fact, it may be simpler to just leave your page how it is. :)

This goes a little above what we tend to offer for support, but I thought it'd be nice to give you an idea of one possible approach:

<?php
list($policiesRecords, $policiesMetaData) = getRecords(array(
'tableName' => 'policies',
'allowSearch' => '0',
));

$policySectionName = array(
"0000" => "Bylaws",
"1000" => "Administration",
"2000" => "Program",
"3000" => "Teaching Staff Members",
"4000" => "Support Staff Members",
"5000" => "Pupils",
"6000" => "Finances",
"7000" => "Property",
"8000" => "Operations",
"9000" => "Community"
);
?>

<?php $currentPolicySection = "none"; ?>
<?php $sectionRecordCount = 999; ?>
<?php foreach ($policiesRecords as $record): ?>
<?php foreach ($record['document'] as $upload): ?>
<?php $thisPolicySection = floor($record['policy_number'] / 1000) . "000" ?>
<?php if ($thisPolicySection != $currentPolicySection): ?>
<?php if ($sectionRecordCount == 0): ?>
<p>Please be patient while we re-structure this section.</p>
<?php endif ?>
<?php $currentPolicySection = $thisPolicySection ?>
<?php $sectionRecordCount = 0 ?>
<p class="policyheader"><?php echo $currentPolicySection ?> - <?php echo @$policySectionName[$currentPolicySection] ?></p>
<?php endif ?>
<p>
<a href="<?php echo $upload['urlPath'] ?>"><?php echo $record['policy_number'] ?> - <?php echo $record['policy_title'] ?></a>
</p>
<?php endforeach ?>
<?php endforeach ?>


I hope this helps!
All the best,
Chris