Forum

Thread tagged as: Question

Need to upload a PDF then create a link to it.

Hello is there a way to upload a PDF then create a link to it in perch?

Aaron Storm

Aaron Storm 0 points

  • 7 years ago

Use the 'file' content tag. https://docs.grabaperch.com/docs/templates/attributes/type/file/

<perch:content id="report" type="file" label="Annual report PDF" />

Or if using CKEDITOR use the 'link' button and then select the upload tab.

My PDF file doesn't seem to be uploading.

<perch:content id="report" type="file" label="Newsletter PDF" bucket="newsletter" />

Also is there a way to edit a script in perch?

<script>
    function Q2Newsletter2014() {
        window.open("../images/Q2-Newsletter-2014.pdf", "_blank", "toolbar=no, scrollbars=yes, resizable=yes, top=50, left=50, width=900, height=500");
    }
</script>
<script>
    function <perch:content type="text" id="doc" title="true" label="Document Label" help="Example: Q2NewsletterApril2014 -No Spaces-"/>() {
        window.open("<perch:content type="text" id="heading" label="File Name" help="Example: Q2-Newsletter-2014.pdf"/>", "_blank", "toolbar=no, scrollbars=yes, resizable=yes, top=50, left=50, width=900, height=500");
    }
</script>

Is there a reason for the Script? I would just use an anchor link with a "target="_blank" as follows:

<a target="_blank" href="<perch:content id="file" type="file" label="File" order="2" />"><perch:content type="text" id="desc" label="Title" order="1" required="true" title="true" /></a>

or add it to a repeater for multiple PDF downloads.

<perch:repeater id="newsletters" label="Newsletters downloads">
<a target="_blank" href="<perch:content id="file" type="file" label="File" order="2" />"><perch:content type="text" id="desc" label="Title" order="1" required="true" title="true" /></a>
</perch:repeater>

Yes the script uses an onclick function to open a new window of a specific size.

https://www.w3schools.com/jsref/met_win_open.asp

In your script you have used type="text" it should be type="file"

<script>
    function <perch:content type="text" id="newsTitle" title="true" label="Document Label" help="Example: Q2NewsletterApril2014 -No Spaces-"/>() {
        window.open("<perch:content type="file" id="pdf" label="Newsletter PDF" help="Example: Q2-Newsletter-2014.pdf" bucket="newsletter"/>", "_blank", "toolbar=no, scrollbars=yes, resizable=yes, top=50, left=50, width=900, height=500");
    }
</script>

That worked.

Thank you.

One more question. Is there a way to have the file upload to a specific location?

Another question. How do I delete docs/pdf and images from the bucket list?

In the Assets App. Click on the image/pdf and then 'Delete' button.

Another question.

I'm trying to add multiple items that will be added above or on top of the item list in stead of below it. Tried using the before tag but that must not be how it's done.

<script>
    function <perch:content type="text" id="doc" title="true" label="Document Label" help="Example: AlejandroArango -No Spaces-"/>() {
        window.open("<perch:content type="file" id="pdf" label="Press Release PDF" help="Example: Welcome Alejandro Arango.pdf" bucket="pressrelease"/>", "_blank", "toolbar=no, scrollbars=yes, resizable=yes, top=50, left=50, width=900, height=500");
    }
</script>

<perch:before>
<div id="element118b">
    <a onclick="<perch:content type="text" id="doc" title="true" label="Document Label" help="Example: AlejandroArango -No Spaces-"/>()">
        <img src="<perch:content type="image" id="image" sharpen="0" label="Image" width="158px" quality="100" bucket="pressrelease"/>" alt="<perch:content type="text" id="heading" label="Heading" help="Example: Welcome Alejandro Arango"/>" />
    </a>

    <a onclick="<perch:content type="text" id="doc" title="true" label="Document Label" help="Example: AlejandroArango -No Spaces-"/>()">
        <h3><perch:content type="text" id="heading" label="Heading" help="Example: Welcome Alejandro Arango"/>
        </h3>
    </a>

    <perch:content id="body" type="textarea" label="Text" textile="true" editor="Markitup" /> <a onclick="<perch:content type="text" id="doc" title="true" label="Document Label" help="Example: AlejandroArango -No Spaces-"/>()">More...</a>
</div>
</perch:before>

Should the 'script' be after your Perch 'before' tags?

If you want the user to add multiple items I would use a 'Repeater' instead of Perch:before

The script can be anywhere because it does on the show up on the webpage.

In perch I'd like to add multiple items that will be added above or on top of the each other instead of below it.

Like when you post a comment in a blog, your post shows up on top or above everyone else.

This is going to be for a press release and the latest or new press release needs to show up on top or above the older ones.

In the 'region options' you can turn on 'allow multiple items' and then under this is an option "new items are..." Change this to "Added to top"

Oh ok thank you.

And I got another question. How do I put a link into a paragraph.

I think I'm using the standard Markitup editor.

Not sure. I use CKEDITOR.

Is there not a 'chain' icon (link) in the toolbar? Highlight the text you wish to link and clink this.

If a PDF file size is very large will that prevent the file from uploading into the assets?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, your server has a configured maximum file upload size.