Uploads issue
2 posts by 2 authors in: Forums > CMS Builder
Last Post: April 12, 2017 (RSS)
By willydoit - April 5, 2017
Hi all,
I have created a table of pdf brochures allowing the client to upload pdf's for clients to download. I have a second upload section so that they can assign an image for each pdf.
My problem is that the code linking to the download for the image and the download to the pdf are exactly the same. I want the image when displayed to link to the pdf download but when I insert the code as shown below it links to the actual image instead. I think can understand why which I assume is that it is currently dealing with the foreach statement dealing with the image display and hasn't got to the foreach element of the pdf upload.
My Question is how do I get cmsb to differentiate between the $upload['urlpath for the pdf and the $upload['urlpath for the image. As both download link codes are identical as shown below.
Thanks in advance for any help provided.
<?php echo htmlencode($upload['urlPath']) ?> For the image upload
<?php echo htmlencode($upload['urlPath']) ?> For the PDF File upload
In my listing page I have the following code
<?php foreach ($brochuresRecords as $record): ?>
<div class="col-sm-3" align="center">
<div class="img-thumbnail-brochure">
<h4 style="color: #ED1C24"><?php echo htmlencode($record['title']) ?></h4>
<?php foreach ($record['image'] as $index => $upload): ?>
<a href="<?php echo htmlencode($upload['urlPath']) ?>"><img alt="<?php echo htmlencode($record['title']) ?>" class=" img-rounded img-responsive" src="<?php echo htmlencode($upload['thumbUrlPath3']) ?>"></a>
<?php endforeach ?>
<div class="caption">
<?php foreach ($record['upload_brochure'] as $index => $upload): ?>
<p><a href="<?php echo htmlencode($upload['urlPath']) ?>" target="_blank">Download Brochure</a> </a>
<?php endforeach ?>
</p>
By ross - April 12, 2017
Hi there.
I see what you mean and have an idea for a solution :).
What I suggest is looking at this:
<?php foreach ($record['upload_brochure'] as $index => $upload): ?>
and changing it to read:
<?php foreach ($record['upload_brochure'] as $index => $brochureUpload): ?>
Notice that I changed "$upload" to "$brochureUpload".
Next, inside that "foreach" block you need to change $upload to $brochureUpload like this:
<?php foreach ($record['upload_brochure'] as $index => $brochureUpload): ?>
<p><a href="<?php echo htmlencode($brochureUpload['urlPath']) ?>" target="_blank">Download Brochure</a> </a>
<?php endforeach ?>
Does that make sense?
Give this a shot and let me know how you make out.
Thanks!
Cheers,
Ross Fairbairn - Consulting
consulting@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: http://www.interactivetools.com/consulting/