Creating/Displaying uploads
3 posts by 2 authors in: Forums > CMS Builder
Last Post: April 4, 2008 (RSS)
By keith_s - April 2, 2008
I'm working on my first installation of CMSB and am trying to create and display uploaded files.
Here's my questions:
Here is the scenario:
Here's an link to a test page that I'm using to try to get this to work: http://www.decaturcountyga.org/hrdocumentsPage.php
[cool] HELP PLEASE...
Here's my questions:
- Do I create a Section Editor like I would for a simple updateable page? If the only field that is going to be used is an "upload" field, then would it be normal for the mysql table shown in the Section Editors list in the CMS manage to have zero entries since the "uploads" table will contain the uploads?
- How do I display the list of files? I've tried every way that I can read about, but simply can't get anything to work.
Here is the scenario:
- I'm using a php include function to call in a table of uploaded files. The php include file is named "navHRinc.php". In the CMS editor, I created a Section Editor with a mysql table named "hrdocuments".
- The HR Documents Section Editor (single page) only has one field, (label: list/name: documentlist/field type: upload).
Here's an link to a test page that I'm using to try to get this to work: http://www.decaturcountyga.org/hrdocumentsPage.php
[cool] HELP PLEASE...
Re: [keith_s] Creating/Displaying uploads
By Dave - April 2, 2008
Hi Keith, welcome to the forums! :)
To answer your questions, yes, you'd create a section editor. Even though the uploads are stored in a separate table they're accessed through the viewer code which displays records from the section editors (I hope that makes sense!).
If you're just going to have one page for documents you might want to set that section to be a "Single Page" editor. You can do that under: Section Editors > HR Documents > Section Type.
What you have setup looks right. Do you have any files uploaded for record 1 in the "HR Documents" section? The page viewer hrdocumentsPage.php will always display record 1 by default unless you specify a different record number on the url (eg: hrdocumentsPage.php?2)
Let me know if you have files uploaded for record 1. If you do and there still not showing up I can always login and take a look. Just email details to dave@interactivetools.com (email, don't post login details in forum).
Hope that helps, let me know if there's anything else I can do to assist.
To answer your questions, yes, you'd create a section editor. Even though the uploads are stored in a separate table they're accessed through the viewer code which displays records from the section editors (I hope that makes sense!).
If you're just going to have one page for documents you might want to set that section to be a "Single Page" editor. You can do that under: Section Editors > HR Documents > Section Type.
What you have setup looks right. Do you have any files uploaded for record 1 in the "HR Documents" section? The page viewer hrdocumentsPage.php will always display record 1 by default unless you specify a different record number on the url (eg: hrdocumentsPage.php?2)
Let me know if you have files uploaded for record 1. If you do and there still not showing up I can always login and take a look. Just email details to dave@interactivetools.com (email, don't post login details in forum).
Hope that helps, let me know if there's anything else I can do to assist.
Dave Edis - Senior Developer
interactivetools.com
interactivetools.com
Re: [Dave] Creating/Displaying uploads
By keith_s - April 4, 2008 - edited: April 4, 2008
Thanks Dave. I appreciate your quick response and resolution to my question. Turns out that I had apparently created the section correctly, but maybe not actually "saved" it. (something weird like that). Also, the code that I was using wasn't exactly correct. I'm posting what I wound up using below so that others can see how to display the contents of an upload.
If you want to see the page in action, visit http://www.decaturcountyga.org/Human_Resources.php and scroll down to the "Documents" section in the left-hand navigation. I've changed the code below slightly to make the foreach loop create a complete table row for each uploaded file that exists.
I am very impressed with this software. Dave, Donna, Luke, and the others are SUPER! One of the best support teams that I've ever run across. This is the same level of service that my company, WebGraffix Media Solutions, offers. Keep it up guys!
Here's the simple version of the code that Dave sent to me. I've changed the table name and the "require_once" value for the sake of security. I also am using the first info field (info1) as the name of the file to display rather than the actual uploaded name of the file.
Again, thanks Dave!!
If you want to see the page in action, visit http://www.decaturcountyga.org/Human_Resources.php and scroll down to the "Documents" section in the left-hand navigation. I've changed the code below slightly to make the foreach loop create a complete table row for each uploaded file that exists.
I am very impressed with this software. Dave, Donna, Luke, and the others are SUPER! One of the best support teams that I've ever run across. This is the same level of service that my company, WebGraffix Media Solutions, offers. Keep it up guys!
Here's the simple version of the code that Dave sent to me. I've changed the table name and the "require_once" value for the sake of security. I also am using the first info field (info1) as the name of the file to display rather than the actual uploaded name of the file.
[font "Arial"]
<!-- STEP1: Load Record (Paste this above other step) -->
<?php
require_once "/usr/public/serverpath/admin/cms/lib/viewer_functions.php";
$options = array(); // NOTE: see online documentation for more details on these options
$options['tableName'] = 'documents'; // (REQUIRED) MySQL tablename to list record from. Example: "article";
$options['recordNum'] = ''; // (optional) Record number to display. Example: "1"; Defaults to number on end of
// url, then 1
$options['where'] = ''; // (ADVANCED) MySQL WHERE conditions to use INSTEAD of recordNum to look up
// record. Example: "fieldname = 'value'"
$record = getRecord($options);
?>
<!-- /STEP1: Load Record -->
<!-- STEP2: Display Record (Paste this where you want your record displayed and re-arrange fields) -->
<h1>HR Documents Page Viewer</h1>
<?php if ($record): ?>
Record Number: <?php echo $record['num'] ?><br/>
<?php endif ?>
<?php if (empty($record)): ?><!-- Display "No Records Found" Message -->
No record found!<br/><br/>
<?php endif ?>
<!-- STEP2: /Display Record -->
<!-- STEP3: Display Uploads from 'documentlist' (Paste this where you want your uploads displayed) -->
<!-- Upload Program Fields : num, createdTime, tableName, fieldName, recordNum, preSaveTempId, filePath,
filename, extension, thumbFilePath -->
<!-- Upload Image Fields : isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight -->
<!-- Upload Info Fields : info1, info2, info3, info4, info5 -->
<?php if ($record): ?>
<?php foreach (getUploads($options['tableName'], 'documentlist', $record['num']) as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>"
height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>
<?php elseif ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>"
alt="" /><br/>
<?php else: ?>
<a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['info1'] ?></a><br/>
<?php endif ?>
<?php endforeach ?>
<?php endif ?>
<!-- STEP3: /Display Uploads from 'documentlist' -->
Again, thanks Dave!!