Change default path of pdf files

Hi
As I know in OJS, papers’ files store without their extensions! I mean when I move cursor on a pdf’s download link I see only the place of file, not the real file address, (e.g http://www.gmj.ir/gmj/index.php/gmj/article/view/414/pdf_69) But when I click on on download link I saw correct file’s name (in my mentioned link, when I click on a download link I see this file name in my download manager “414-2621-1-PB.pdf”).
Is there any way to add file name at end of paper’s link? (I want, when my users move their cursors on a paper file see a link like this: “http://www.gmj.ir/gmj/index.php/gmj/article/view/414/414-2621-1-PB.pdf” NOT “http://www.gmj.ir/gmj/index.php/gmj/article/view/414/pdf_69”)
Please help…

Thanks in advance

Best Regards
Amir

Hi @Amir_Darejeh,

Off the top of my head, I think OJS will ignore any additional content you add to the URL, so wherever you present a link to the file you could just add the desired fliename to the end. For example, rather than…

http://www.gmj.ir/gmj/index.php/gmj/article/view/414/pdf_69

…you could append the filename…

http://www.gmj.ir/gmj/index.php/gmj/article/view/414/pdf_69/414-2621-1-PB.pdf

The last part will be totally ignored but will appear in the URL. To do this you’d need to modify the template files where the URLs you want to change are generated.

However, I’m not sure why you’d want to make this change.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher
Thanks for your response
Actually my boss asked me to do this change, So I don’t have any idea, Why!!
I inspected article.tpl and found these lines of code that relevant to pdf links:

{foreach from=$article->getGalleys() item=galley name=galleyList} getBestArticleId($currentJournal)|to_array:$galley->getBestGalleyId($currentJournal)}" class="file" target="_parent">{$galley->getGalleyLabel()|escape} {if $subscriptionRequired && $showGalleyLinks && $restrictOnlyPdf} {if $article->getAccessStatus() == $smarty.const.ARTICLE_ACCESS_OPEN || !$galley->isPdfGalley()} {translate key= {else} {translate key= {/if} {/if} {/foreach} But unfortunately, I don't know how can I add the pdf link at end of the URL. I think, I should make some changes in articleHandler.php too!!

Could you help me to find the right place for making changes?

Best Regards
Amir

Hi @Amir_Darejeh,

The link is generated by this code:

 <a href="{url page="article" op="view" path=$article->getBestArticleId($currentJournal)|to_array:$galley->getBestGalleyId($currentJournal)}" class="file" {if $galley->getRemoteURL()}target="_blank"{else}target="_parent"{/if}>{$galley->getGalleyLabel()|escape}</a>

The important part is this attribute…

path=$article->getBestArticleId($currentJournal)|to_array:$galley->getBestGalleyId($currentJournal)

You can add another part of the path by adding to the end, separating with : characters:

path=$article->getBestArticleId($currentJournal)|to_array:$galley->getBestGalleyId($currentJournal):newPartHere

To get the filename, use the getFileName function:

path=$article->getBestArticleId($currentJournal)|to_array:$galley->getBestGalleyId($currentJournal):$galley->getFileName()

I haven’t tested any of this, but it should work.

Regards,
Alec Smecher
Public Knowledge Project Team

Thank you Alec for your quick respond
It’s worked :slight_smile: But I want to change another URL in a single article view at the top of
This page we can see “Download this PDF file” link that give us real download link, But when I move my cursor on it, I still see a link without file extension. I looked up all files in article template folder and found these lines of code in “pdfViewer.tpl”

    <div id="pdfDownloadLinkContainer">
	<a class="action pdf" id="pdfDownloadLink" target="_parent" href="{url op="download" path=$articleId|to_array:$galley->getBestGalleyId($currentJournal):$galley->getFileName()}">{translate key="article.pdf.download"}</a>
</div>

But any changes that I made in these codes didn’t give me any result!!

Please help

Regards
Amir

Hi
anybody there? :neutral_face:

What code did you try in pdfViewer.tpl?

Hi
when I add anything to these lines of code, I can’t see any change in article/view. I added even plain text in body of link, but I can’t see anything!!

<div id="pdfDownloadLinkContainer">
	<a class="action pdf" id="pdfDownloadLink" target="_parent" href="{url op="download" path=$articleId|to_array:$galley->getBestGalleyId($currentJournal):$galley->getFileName()}">{translate key="article.pdf.download"}</a>
</div>

In the above code I added :$galley->getFileName() at the end of the path, But I can’t see any change in article/view page.

Please help

Regards
Amir

You appear to be using the Google PDF Viewer plugin. See the code under:

To ensure you catch each possible download link, you will want to search for usages of {translate key="article.pdf.download"}.

Thank you Graham
It’s work :smile:

Regards
A,or