Open PDF in a new tab

in Download Manager Free

Viewing 7 posts - 1 through 7 (of 7 total)
Apr 9, 2021 at 6:05 am
#150150
Participant
Arianna Bianchi
OP

Hi, How can I open a PDF file in a new tab? I’m currently using the button template and this is the code embeded into my page:
[wpdm_button_template id=”841″ style=”blue” align=”center”]

I just need all the PDF files to open in a new tab rather than in the same as the website.

Many Thanks!

Apr 9, 2021 at 7:16 am
#150157
Moderator
Nayeem Riddhi
Staff

Hi,
you can follow the link below documentation,

Template Files


by default, you are using link-template-default.php for link template and page-template-default.php for the page template. As documentation, you have to copy the file in the theme directory naming a folder called download-manager, then paste it in tpls>page-templates for page template or tpls>link-templates for link template. And you have to replace [download_link] with <a href="[download_url]" class="btn btn-primary" target=_blank>[link_label]</a> in related php file.

Thanks.

Apr 19, 2021 at 12:32 am
#150692
Participant
Simon Frost

Hi Nayeem, I am working on this project with Arianna and am trying to make these changes. I understand what you’ve written, but as we’re using the WPDM Button Templates add-on I think the template file is located elsewhere – it’s probably coming from plugins/wpdm-button-templates/wpdm-button-templates.php

The trouble I have now is that the [download_link] text is in code like this:

if(!wpdm_is_locked($id) && wpdm_user_has_access($id)){
  return "<a href='".wpdm_download_url($package)."'>{$html}</a>";
} else
  return FetchTemplate("[download_link]", $package);

I’m not sure how to replace or modify this without breaking the code – I’m not a PHP developer so I’m just using educated guesses here.

Apr 21, 2021 at 2:53 pm
#150859
Spectator
Humayon

Hello Simon,
Hope you are well.
Please replace the above-mentioned 2nd line with the below code.
return "<a href='".wpdm_download_url($package)."' target=_blank>{$html}</a>";
Hopefully it will solve your issue.
Thanks.

Apr 21, 2021 at 11:32 pm
#150890
Participant
Simon Frost

Hi Humayon,
Thanks so much for that code – I applied it to the file and it is working.

I just want to confirm how I would go about relocating the edited file elsewhere so the change survives plugin upgrades? Similar to the original response in this thread, would I create a folder within the child-theme called wpdm-button-templates and put the edited file there?

Apr 21, 2021 at 11:37 pm
#150891
Participant
Simon Frost

I also have a closely related question, but to do with the wpdm_tree shortcode that comes from the WPDM Extended Shortcodes add-on.

This is the code I’m using to generate a file tree:
[wpdm_tree newwin=1 download_link=1 category="about-us"]

I was looking at the code to work out where to put the target=_blank code so that these links would open in a new tab as well, and while in the PHP file I found an undocumented shortcode parameter called newwin which appears to add the target=_blank to the generated link tree.. except it doesn’t work. I can see in the page source that target="_blank" is part of the <a tag, but when I click the link it opens in the same window anyway. Is there JavaScript somewhere that’s overriding this?

Thanks so much for your help here!

Apr 22, 2021 at 2:41 pm
#150945
Spectator
Humayon

Hi,
You are welcome.
Since WPDM – Button Templates is a small plugin so we do not release its update often.

You can take a backup of the plugins/wpdm-button-templates/wpdm-button-templates.php file so that in future you do not lose it with an update or even you can note the line number where you have edited.

Also, the child-theme wpdm-button-templates override method will not work in this circumstance.

However, We have released an update(2.8.8) of the WPDM Extended Short-codes plugin which will fix the target=_blank issue.
Thanks

Viewing 7 posts - 1 through 7 (of 7 total)

The topic "Open PDF in a new tab" is closed to new replies.