Display Upload Files - DragSortOrder
5 posts by 2 authors in: Forums > CMS Builder
Last Post: January 25, 2012 (RSS)
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
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
northernpenguin
Northern Penguin Technologies
"Any sufficiently advanced technology
is indistinguishable from magic."
........Arthur C. Clarke
Re: [northernpenguin] Display Upload Files - DragSortOrder
By Jason - January 24, 2012
Hi Ragi,
So what you need to do is start by only getting the first record from your record set:
example:
Next, if you were able to get a record, attempt to get the first upload from that record.
example:
Hope this helps
So what you need to do is start by only getting the first record from your record set:
example:
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:
<?php if (@$newsRecord['uploads']); ?>
<?php $upload = $newsRecord['upload'][0]; // get first upload ?>
// output $upload here
<?php endif ?>
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/
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] Display Upload Files - DragSortOrder
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:
<?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
northernpenguin
Northern Penguin Technologies
"Any sufficiently advanced technology
is indistinguishable from magic."
........Arthur C. Clarke
Re: [northernpenguin] Display Upload Files - DragSortOrder
By Jason - January 25, 2012
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:
Hope this helps
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:
<?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 - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
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] Display Upload Files - DragSortOrder
That's great Jason! Thank you, it worked perfectly.
--
northernpenguin
Northern Penguin Technologies
"Any sufficiently advanced technology
is indistinguishable from magic."
........Arthur C. Clarke
northernpenguin
Northern Penguin Technologies
"Any sufficiently advanced technology
is indistinguishable from magic."
........Arthur C. Clarke