Create list from uploads field in combo viewer

9 posts by 2 authors in: Forums > CMS Builder
Last Post: March 24, 2016   (RSS)

By mattbcd - March 7, 2016

Hi

In a combo list viewer I'm trying to create a list which links directly to the upload for each record rather than to the detail page for each. See http://bathresidents.org.uk/minutesTest.php

Each upload is a pdf, so I just need the user to be able to click one of the archived links at the bottom and load that pdf rather than have to click through to another page in order to download it. 

Is this possible?  The only field I could specify for the list in the code generator was 'title', so ideally I'd like to be able to specify 'upload' instead.

Thanks

Matt Harpham

By Damon - March 7, 2016

Hi Matt,

Yes, linking to the PDFs directly can work.

Could you reply with the minutesTest.php template attached so I can look at the code and make suggestions?

Cheers,
Damon Edis - interactivetools.com

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

By Damon - March 8, 2016

Hi Matt,

Just reviewing your code. For the PDF links you want in the More Meeting Minutes part of the page, which upload field is it? pdf or pdf2?

I see that in the Latest Meeting part of the page you have both pdf and pdf2 upload fields so you could have both linked to one after another?

Let me know.

Cheers,
Damon Edis - interactivetools.com

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

By mattbcd - March 8, 2016

Hi Damon

Ideally it's both, but only if the 2nd pdf exists. 

Matt

By Damon - March 8, 2016

OK, that makes sense but what does that look like?

Does the title display twice if there is a upload for pdf and an upload for pdf2?

Cheers,
Damon Edis - interactivetools.com

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

By mattbcd - March 8, 2016 - edited: March 8, 2016

Ah, good question. Maybe append (2) to the title name of the 2nd pdf.

Matt

By Damon - March 9, 2016

Hi Matt,

Here are some code updates for the More Meeting Minutes part of the page:

<div id="archive">More Meeting Minutes</div>
<p class="smallbold">
    <?php foreach ($minutesRecords as $listRecord): ?>

       <?php foreach ($listRecord['pdf'] as $index => $upload): ?>
         <a href="<?php echo $upload['urlPath'] ?>"><?php echo htmlencode($listRecord['title']) ?></a><br/>
       <?php endforeach; ?>

       <?php foreach ($listRecord['pdf2'] as $index => $upload): ?>
         <a href="<?php echo $upload['urlPath'] ?>"><?php echo htmlencode($listRecord['title']) ?> (2)</a><br/>
        <?php endforeach; ?>

    <?php endforeach ?>
</p>     

Also, at the top of the page code around line 40, make sure that you have uploads set to load and display:

// load list records from 'minutes'

  list($minutesRecords, $minutesMetaData) = getRecords(array(
    'tableName'   => 'minutes',
    'limit'       => '10',
    'loadUploads' => true,
    'allowSearch' => false,

  ));


Let me know if this works as expected.

Cheers,
Damon Edis - interactivetools.com

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

By mattbcd - March 24, 2016

Hi Damon

Superb!  Worked a treat. Thanks so much for your time!

Matt