Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the CollectiveAccess support forum! Here the developers and community answer questions related to use of the software. Please include the following information in every new issue posted here:

  1. Version of the software that is used, along with browser and version

  2. If the issue pertains to Providence, Pawtucket or both

  3. What steps you’ve taken to try to resolve the issue

  4. Screenshots demonstrating the issue

  5. The relevant sections of your installation profile or configuration including the codes and settings defined for your local elements.


If your question pertains to data import or export, please also include:

  1. Data sample

  2. Your mapping


Answers may be delayed for posts that do not include sufficient information.

How to download PDFs from metadata element that is a File datatype?

I created a metadata element called "documentation_info" for objects, which has a datatype 'File'. I use documentation_info to attach PDFs to the object -- things like donation agreement letters, MSDS sheets, contracts, historical documents on the artifact ... it's sort of a catch all.

In providence, I can go to the summary view for an object and there's a little download icon next to each PDF that I can click to retrieve my PDFs. (See attached photo.) Is there a way to replicate this in Pawtucket?

I'm running Pawtucket 2 with Providence 1.7.3.

I assume there's a way to do this, since you can download photos/object representations in Pawtucket. So far, I've created a custom theme and modified [mytheme]/views/Details/ca_objects_default_html.php so that documentation_info shows up, but all I see is the filename. (See the code snippet below, and the next attached photo.) How do I add a download link? Do I have to request it somehow through the mysql database? I have to admit I'm a bit of a novice when it comes to php and mysql...any help would be appreciated!

<!-- documentation info (uploaded PDFs) -->
{{{<ifdef code="ca_objects.documentation_info"><HR><H6>Documentation info:</H6>
     <span class="trimText"><unit delimiter="<br/>">^ca_objects.documentation_info</unit></span>
</ifdef>}}}

Comments

  • Hi prothjohnson,

    There is a relatively new option that allows you to output the media url so you can construct a download link.  Try:

    <?php
    print $t_object->get('ca_objects.documentation_info', array("version" => "original", "return" => "url"));
    ?>
  • Thanks, sophie! That helped a lot.

    For reference, here's how I ultimately solved the problem:

    <!-- documentation info (uploaded PDFs) -->
    {{{<ifdef code="ca_objects.documentation_info"><HR><H6>Documentation info:</H6>
            <span class="trimText">
            <?php
                    $names = $t_object->get(
                            'ca_objects.documentation_info',
                            array("returnAsArray"=>true));
                    $links = $t_object->get(
                            'ca_objects.documentation_info',
                            array("version"=>"original", "return"=>"url", "returnAsArray"=>true));
                    $arrlength = count($names);
                    for($x=0; $x<$arrlength; $x++) {
                            echo "<a href=" . $links[$x] . " target='_blank'>" . $names[$x] . "</a>";
                            echo "<br/>";
                    }
            ?>
            </span>
    </ifdef>}}}
Sign In or Register to comment.