Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Print svg file content from custom theme inside Web Content FTL
Alessandro Candini, modified 6 Years ago.
Regular Member
Posts: 130
Join Date: 10/17/15
Recent Posts
Hi everyone.
I have an SVG file under my custom theme: /my-custom-theme/images/circle.svg.
In a freemarker Web Content template I would like to print that icon markup.
How to read that file and print it inside my template?
Thank you.
I have an SVG file under my custom theme: /my-custom-theme/images/circle.svg.
In a freemarker Web Content template I would like to print that icon markup.
How to read that file and print it inside my template?
Thank you.
Alessandro Candini, modified 6 Years ago.
Regular Member
Posts: 130
Join Date: 10/17/15
Recent Posts
Solved in the following way:
<#assign
SystemProperties = staticUtil["com.liferay.portal.kernel.util.SystemProperties"]
fileUtil = staticUtil["com.liferay.portal.kernel.util.FileUtil"]
catalinaHome = SystemProperties.get("catalina.home")
svgFilePath = catalinaHome + "/webapps" + themeDisplay.getPathThemeRoot() + "/images/circle.svg"
svgFileContent = fileUtil.read(svgFilePath)
docXml = saxReaderUtil.read(svgFileContent)
iconSVGMarkup = docXml.getRootElement().asXML()
/>
${iconSVGMarkup}