Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder:
Display Upload Files - DragSortOrder

 

 


northernpenguin
User

Jan 23, 2012, 2:01 PM

Post #1 of 5 (657 views)
Shortcut
Display Upload Files - DragSortOrder Can't Post

I have a multi-record section that includes an "upload" field. Each record typically includes 10 to 12 upload files.

I would like to be able to display on my webpage, the top uploaded file from the topmost record.

For example, if I have the following data:
Record 1
- file 1
- file 2
- file 3
Record 2
- file 1
- file 2

I want to only display Record 1 File 1.

Any ideas how I would attack this problem?

Ragi
--
northernpenguin
Northern Penguin Technologies

"Any sufficiently advanced technology
is indistinguishable from magic."
........Arthur C. Clarke


Jason
Staff / Moderator


Jan 24, 2012, 9:59 AM

Post #2 of 5 (623 views)
Shortcut
Re: [northernpenguin] Display Upload Files - DragSortOrder [In reply to] Can't Post

Hi Ragi,

So what you need to do is start by only getting the first record from your record set:

example:


Code
list($newsRecords, $newsMetaData) = getRecords(array( 
'tableName' => 'news',
));

$newsRecord = @$newsRecords[0]; //retrieve the first record from the record set


Next, if you were able to get a record, attempt to get the first upload from that record.

example:


Code
<?php if (@$newsRecord['uploads']); ?> 
<?php $upload = $newsRecord['upload'][0]; // get first upload ?>

// output $upload here

<?php endif ?>


Hope this helps
---------------------------------------------------
Jason Sauchuk - Programmer 
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/ 


northernpenguin
User

Jan 24, 2012, 5:53 PM

Post #3 of 5 (612 views)
Shortcut
Re: [Jason] Display Upload Files - DragSortOrder [In reply to] Can't Post

Hi Jason: Thank you, it got me on the right path, but I am having a minor issue. The output prints twice for some reason. I've played with it, but I can't get it to print only once. Here is my code:

Code
		 
<?php foreach ($albatrossRecords as $record): ?>

<?php foreach ($record['file_upload'] as $upload): ?>

<?php if (@$albatrossRecord['file_upload']): ?>
<?php $upload = $albatrossRecord['file_upload'][0]; // get first upload ?>

Latest Issue: <a href="<?php echo $upload['urlPath'] ?>"><?php echo $upload['info1'] ?></a>

<?php endif ?>


<?php endforeach ?>
<?php endforeach ?>

--
northernpenguin
Northern Penguin Technologies

"Any sufficiently advanced technology
is indistinguishable from magic."
........Arthur C. Clarke


Jason
Staff / Moderator


Jan 25, 2012, 10:35 AM

Post #4 of 5 (605 views)
Shortcut
Re: [northernpenguin] Display Upload Files - DragSortOrder [In reply to] Can't Post

Hi,

Do you have multiple records outputting, or the same upload showing up more than once? If it's the latter, try removing your nested foreach look like this:


Code
<?php foreach ($albatrossRecords as $record): ?>  

<?php if ($record['file_upload']): ?>
<?php $upload = $record['file_upload'][0]; // get first upload ?>

Latest Issue: <a href="<?php echo $upload['urlPath'] ?>"><?php echo $upload['info1'] ?></a>

<?php endif ?>

<?php endforeach ?>


Hope this helps
---------------------------------------------------
Jason Sauchuk - Programmer 
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/ 


northernpenguin
User

Jan 25, 2012, 11:16 AM

Post #5 of 5 (604 views)
Shortcut
Re: [Jason] Display Upload Files - DragSortOrder [In reply to] Can't Post

That's great Jason! Thank you, it worked perfectly.
--
northernpenguin
Northern Penguin Technologies

"Any sufficiently advanced technology
is indistinguishable from magic."
........Arthur C. Clarke