简体   繁体   中英

Liferay 7.1 - How to add a link html for a pdf file

I have a main module C-portlet that contains in the folder resources a pdf file.

resources/webapp/files/cg.pdf

I have a war theme. In one of its jsp page, i need to add a link for the cg.pdf.

For now, i have :

<a target="_blank" href="/o/Cportlet/src/main/resources/META-INF/resources/webapp/files/cg.pdf"><liferay-ui:message key="cg-link"/></a>

but it doesn't work.

Last point, this pdf could be changed at anytime without a deploy again a module / war.

Is anyone have an idea ?

Thanks

You can put your pdf file in one of your theme resource folders (for example the "templates" folder).

Now you can use themeDisplay.getPathThemeTemplates() + "/cg.pdf" or within your theme with freemarker "${templates_folder}/cg.pdf"

There are several ways to do this: imagining you cannot use the regular documents library... Or you module cannot use the library to get resources..

You could use a resource action if you have an MVC portlet. This would be the simplest way to just serve that resource, and you would only need to put the MVC resource command URL in you jsp. Regular portlets can also provide resources but not as easily.

For general modules you can create a struts action..which are normally way more complicated, especially if the resource is for private use only.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM