Skip Navigation

[Resolved] Button to display PDF (URL stored in custom field) in new window

This support ticket is created 3 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 9 replies, has 2 voices.

Last updated by Shane 3 years, 7 months ago.

Assisted by: Shane.

Author
Posts
#2040629

In my web directory I have a sub-directory containing PDF files related to my products. I have a custom field in the Product CPT containing the respective PDF URL. I want to have a 'button' on my single product Content Template that displays that PDF in a new window when clicked. Is this possible, and if so how do I accomplish this?

#2041221

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

button dynamic source.PNG

Hi Anthony,

Thank you for getting in touch. If you are using the Gutenburg editor you can simply Add the Toolset Button element to your template and select a Dynamic source for the URL . See Screenshot

This should allow you to select the file field that contains your pdf. You can also set the field to open in a new tab when clicked.

Please let me know if this helps.

Thanks,
Shane

#2041237

Hi Shane - what you've suggested is exactly what I have in place now; the 'Onesheet' button on hidden link , for example. Problem is, the PDF file gets downloaded, when what I'd like is for it to display in a window... This is a development site, also fully backed up, and I'm happy to give you full access if you'd like to look around...

#2041257

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Anthony,

Thank you for the link to the page. In my case the PDF file doesn't download.

I'm taken to a new tab as intended. Also I can see the target='_blank' being displayed on the HTML link for this which indicates that it will open in a new tab.

Can you try on a different browser? Perhaps your browser is caching the old page.

Thanks,
Shane

#2041351

You're right, Shane - it is working properly in another browser! So I have a different but related question - is there a way to have the PDF display within a themed page, i.e. like images do on an attachment page?

#2041531

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Anthony,

is there a way to have the PDF display within a themed page

I'm not sure what you're referring to can you provide further clarity on this for me ?

Thanks,
Shane

#2041563

Right now the PDF displays alone in a new window. Is there a way to have the selected theme's header and footer sections appear in their respective positions above and below the PDF?

#2041581

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Anthony,

Actually no this isn't possible to do. Mainly because you are opening a direct URL to the file, so the file itself will get rendered.

This is independent of the website settings and design since its a direct file url.

Thanks,
Shane

#2041629

Another support thread I found earlier - https://toolset.com/forums/topic/display-uploaded-pdf-file/ - refers to the plugin pdf-embedder plugin, which I have now installed .. is there maybe a way for a button to execute a dynamically composed shortcode like [pdf-embedder url="[types field='your-pdf-field' output='raw'][/types]"] resulting in a new page?

#2041657

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Anthony,

The plugin that was used there i believe is to embed the PDF onto the page itself. The button won't be able to process this shortcode as it will need to be added directly to the page that you are embedding it to.

There is a way to do this by creating a static page and adding a view to the page and pass the post ID of the page into the URL to filter the view so that you will get the correct PDF file being embedded onto the page.

The main issue is that the link to the page would need to be constructed manually like this.

<a href='linktopdfpage?id=[wpv-post-id]'>Click to PDF</a>

You will need to style the anchor tag to appear like a button. Please let me know what you think of this and we can proceed with getting this implemented.

Thanks,
Shane