 |

dwelling
User
Jul 10, 2008, 9:26 PM
Post #1 of 10
(954 views)
Shortcut
|
|
List most recent uploads
|
Can't Post
|
|
Hello. I'm familiar with how to display the most recent records. But, is there a way to display the 5 most recent uploads, for instance, for a certain record? Thanks, in advance, for the help! Jeremy
|
|
|  |
 |

Jake
Staff
/ Moderator

Jul 12, 2008, 8:58 PM
Post #2 of 10
(924 views)
Shortcut
|
|
Re: [dwelling] List most recent uploads
[In reply to]
|
Can't Post
|
|
Hi Jeremy, Just to clarify, did you need to do this for one specific record only, or all records in a section? Did you want to set this up for a list viewer page or a detail viewer page? I look forward to hearing from you! ----------------------------------------------------------- Cheers, Jake Swanson - Product Specialist support@interactivetools.com
Hire me! Save time by getting our experts to help with your project. Template changes, advanced features, full integration, whatever you need. Whether you need one hour or fifty, get it done fast with Priority Consulting.
|
|
|  |
 |

dwelling
User
Jul 12, 2008, 11:44 PM
Post #3 of 10
(918 views)
Shortcut
|
|
Re: [Jake] List most recent uploads
[In reply to]
|
Can't Post
|
|
Hi Jake! Thanks so much for the response. I think it would be best in my situation to have it list the 5 most recent uploads among any (all) of the records in the section. As for the second question, the uploads are on the detail pages, but I would like to draw from those and place the most recent ones on the main list page. Hopefully that makes sense. Thanks, Jeremy
|
|
|  |
 |

Jake
Staff
/ Moderator

Jul 14, 2008, 1:12 PM
Post #4 of 10
(887 views)
Shortcut
|
|
Re: [dwelling] List most recent uploads
[In reply to]
|
Can't Post
|
|
Hi Jeremy, I tested this code out on my end and it looks like it will do the job for you:
<?php list($uploadRecords, $uploadMetaData) = getRecords(array( 'tableName' => 'uploads', 'where' => 'tableName = "YOUR_SECTION_TABLE_NAME" && fieldName = "YOUR_UPLOAD_FIELD_NAME"', 'orderBy' => 'createdTime DESC', 'limit' => '5', )); $upload = @$uploadRecords[0]; // get first record ?> <?php foreach ($uploadRecords as $record): ?> <a href="<?php echo $record['urlPath'] ?>"><?php echo $record['info1'] ?></a><br /> <?php endforeach ?> That code should do the trick on your list viewer page. Just replace "YOUR_SECTION_TABLE_NAME" and "YOUR_UPLOAD_FIELD_NAME" with the correct values from your installation. Let us know if you need anything else. ----------------------------------------------------------- Cheers, Jake Swanson - Product Specialist support@interactivetools.com
Hire me! Save time by getting our experts to help with your project. Template changes, advanced features, full integration, whatever you need. Whether you need one hour or fifty, get it done fast with Priority Consulting.
|
|
|  |
 |

dwelling
User
Jul 15, 2008, 12:34 PM
Post #5 of 10
(873 views)
Shortcut
|
|
Re: [Jake] List most recent uploads
[In reply to]
|
Can't Post
|
|
Jake, I've been away from my computer for a couple of days so I haven't tried this yet. But I wanted to at least acknowledge, and thank you for, your post. Your assistance is very much appreciated. I'll let you know how it goes. Jeremy
|
|
|  |
 |

Perchpole
User
Jul 15, 2008, 6:09 PM
Post #6 of 10
(825 views)
Shortcut
|
|
Re: [dwelling] List most recent uploads
[In reply to]
|
Can't Post
|
|
Hi, All - I can confirm that this does work. However, on it's own, it isn't ideal as it relies to heavily on "info1" data for identification purposes. I think it would be much more useful if you were to combine this code with the code Dave put together in answer to my random images post... Forum Link In this instance, the code not only pulls out the image but also the record that goes with it. In this way you can identify the image with the record name/title as well as providing a link straight back to the record. I've tried to adapt Dave's code to work with Jake's code (above). <?php require_once "/xyz/viewer_functions.php"; list($uploadRecords, $uploadMetaData) = getRecords(array( 'tableName' => 'uploads', 'where' => 'tableName = "catalogue" && fieldName = "images"', 'orderBy' => 'createdTime DESC', 'limit' => '5', )); $upload = @$uploadRecords[0]; // get first record // load record $recordNum = @$upload['recordNum']; list($productRecords, $productMetaData) = getRecords(array( 'tableName' => 'catalogue', 'where' => "num = '$recordNum'", 'limit' => '5', )); $product = @$productRecords[0]; // get first record ?> <?php foreach ($uploadRecords as $record): ?> <a href="<?php echo $product['_link'] ?>"><IMG SRC="<?php echo $record['thumbUrlPath'] ?>" /> <BR /> <?php echo $product['title'] ?></a> <?php endforeach ?> The foreach code above is meant to display the thumbnail of the image with the title of the corresponding record underneath. Both the thumb and the the title act as a link back to the record. Unfortunately, although it does indeed display the thumbs of the 5 most recently uploaded images, the link and title data is only correct in the first instance. The same data is repeated for each of the 4 remaining thumbs. Is there anyway to fix this? :0) Perch
|
|
|  |
 |

Dave
Staff
/ Moderator

Jul 16, 2008, 10:45 PM
Post #7 of 10
(808 views)
Shortcut
|
|
Re: [Perchpole] List most recent uploads
[In reply to]
|
Can't Post
|
|
Hi Perch, There's no easy way to do that. It would require a bit of custom programming. One thing you could try is looping over the uploads and then looking up each record one at a time in the foreach loop: <?php foreach ($uploadRecords as $upload): ?> // get first record $recordNum = @$upload['recordNum']; list($productRecords, $productMetaData) = getRecords(array( 'tableName' => 'catalogue', 'where' => "num = '$recordNum'", 'limit' => '5', )); $product = @$productRecords[0]; ?> I haven't tried it, but I think that should work the way you want. Dave Edis - Senior Developer interactivetools.com
(This post was edited by Dave on Jul 17, 2008, 9:08 AM)
|
|
|  |
 |

Perchpole
User
Jul 17, 2008, 2:21 AM
Post #8 of 10
(803 views)
Shortcut
|
|
Re: [Dave] List most recent uploads
[In reply to]
|
Can't Post
|
|
Hi, Dave - Thanks for you input. However, I'd be grateful if you could explain the code a little beeter. There appears to be at least one set of brackets missing and I'm not at all sure where the code block is supposed to go... Rather flumoxed! :0) Perch
|
|
|  |
 |

Dave
Staff
/ Moderator

Jul 18, 2008, 1:50 PM
Post #9 of 10
(705 views)
Shortcut
|
|
Re: [Perchpole] List most recent uploads
[In reply to]
|
Can't Post
|
|
I had missed a slash. I added it above in red. Here's the basic code. I used print_r to display all the variables. Hopefully you can figure it out from this.
<?php require_once "C:/wamp/www/sb/core2/admin/lib/viewer_functions.php"; list($uploadRecords, $uploadMetaData) = getRecords(array( 'tableName' => 'uploads', 'where' => 'tableName = "news" && fieldName = "uploads"', 'orderBy' => 'createdTime DESC', 'limit' => '5', )); ?> <?php foreach ($uploadRecords as $upload): ?> <?php $recordNum = @$upload['recordNum']; list($productRecords, $productMetaData) = getRecords(array( 'tableName' => 'news', 'where' => "num = '$recordNum'", 'limit' => '1', )); $product = @$productRecords[0]; ?> <h2>Upload Fields</h2> <xmp><?php print_r($upload); ?></xmp> <h2>Record Fields</h2> <xmp><?php print_r($product); ?></xmp> <hr /> <?php endforeach ?> You'll need to change the table names and a few things, but this should get you on your way. Hope that helps! Dave Edis - Senior Developer interactivetools.com
|
|
|  |
 |

Perchpole
User
Jul 20, 2008, 3:08 PM
Post #10 of 10
(684 views)
Shortcut
|
|
Re: [Dave] List most recent uploads
[In reply to]
|
Can't Post
|
|
Dave - It works a treat. Thanks a lot! :0) Perch
|
|
|  |
|