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?
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.
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...
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.
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?
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?
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?
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.