Home | Products | Consulting | Forums | Support | Order | 1-800-752-0455
  Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder:
Feature most recent file upload

 

 


jdancisin
User

Jul 17, 2008, 10:05 AM

Post #1 of 3 (417 views)
Shortcut
Feature most recent file upload Can't Post

My client needs to upload a new file to a page each month. The most recent file needs to be highligted in some way, and the older files need to remain visible but in a clearly separate section of the page. I know this can be done by setting up two different file uploads, but I was wondering if there is a way for it to be done with just a single upload (to make things simpler for the client). here is the current version, using a single upload, which just generates a single list of files.


Code
 
<?php
require_once "/usr/www/users/fluency/cmsAdmin/lib/viewer_functions.php";

list($customRecords, $customDetails) = getRecords(array(
'tableName' => 'custom',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$customRecord = $customRecords[0]; // get first record

?>
<?php echo "<?xml version='1.0'?>\n"; ?>
<!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">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<style type="text/css">
body { font-family: arial; }
.instructions { border: 3px solid #000; background-color: #EEE; padding: 10px; text-align: left; margin: 25px}
</style>
</head>
<body>
<h1>File Viewer</h1>
<ul>
<?php foreach ($customRecord['archived_files'] as $upload): ?>
<li><a href="<?php echo $upload['urlPath'] ?>"><?php echo $upload['info1'] ?></a></li>
<?php endforeach ?>
</ul>

</body>
</html>



jdancisin
User

Jul 18, 2008, 10:54 AM

Post #2 of 3 (370 views)
Shortcut
Re: [jdancisin] Feature most recent file upload [In reply to] Can't Post

my post is so lonely Unimpressed


Dave
Staff / Moderator


Jul 18, 2008, 3:07 PM

Post #3 of 3 (352 views)
Shortcut
Re: [jdancisin] Feature most recent file upload [In reply to] Can't Post

jdancisin,

Thanks for your patience!

Can we assume that the "newest" upload will always be sorted to the top? If so you could just use two viewers and a counter to keep track of the upload we're displaying. Here's the code:


Code
<h1>File Viewer 1</h1> 
<ul>
<?php $uploadCount = 0; ?>
<?php foreach ($customRecord['archived_files'] as $upload): ?>
<?php if (++$uploadCount > 1) { continue; } ?>
<li><a href="<?php echo $upload['urlPath'] ?>"><?php echo $upload['info1'] ?>...</a></li>
<?php endforeach ?>
</ul>

<h1>File Viewer 2</h1>
<ul>
<?php $uploadCount = 0; ?>
<?php foreach ($customRecord['archived_files'] as $upload): ?>
<?php if (++$uploadCount < 2) { continue; } ?>
<li><a href="<?php echo $upload['urlPath'] ?>"><?php echo $upload['info1'] ?>...</a></li>
<?php endforeach ?>
</ul>


A little explanation for the code. The ++$variable means "add one to this" and "continue" means skip the rest and continue with the next item in the foreach.

And if you want them in reverse order (with the bottom upload showing first, just replace _both_ foreach lines with this:

<?php foreach (array_reverse($customRecord['archived_files']) as $upload): ?>

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com

 
 
 


Search for (options)
Products
CMS Builder
Article Manager
Realty Manager
Listings Manager
Order Now
Services
Priority Consulting
Support
Online Documentation
Support Forums
Support Homepage
Company Info
12 reasons to choose us!
Meet the team
Monthly newsletter
Contact Us
Toll Free: 1-800-752-0455
Phone: (604) 689-3347
Sales | Support
Conditions of Use | Privacy Policy | Copyright © interactivetools.com 2008
#201 - 2730 Commercial Drive, Vancouver BC Canada V5N 5P4