scmos
(Oscar Sanchez V)
March 13, 2020, 8:06pm
1
How can I get the current theme used so I can use it as URL in a template file using "TAL".
I have this code using TAL:
<div tal:define="pdf nocall:context/pdf" tal:condition="nocall:pdf">
<a tal:attributes="href string:${context/absolute_url}/@@display-file/pdf/${context/pdf/filename}">
<img tal:attributes="src string:$portal_url/img/icn/pdf_icn.svg">
</a>
</div>
And i need to point to the icon url in the current theme
phil31
(Philipp Hewera)
March 16, 2020, 7:44am
2
Are you looking for something like this?
src="++theme++theme.package/img/icn/pdf_icn.svg"
scmos
(Oscar Sanchez V)
March 17, 2020, 7:57pm
3
Yes, but ++theme++theme.package must be the current theme like a variable
phil31
(Philipp Hewera)
March 18, 2020, 7:22am
4
Ok, i got the point. Maybe this will help you to get the icon-path of the current theme.
from plone.app.theming/blob/master/src/plone/app/theming/policy.py :
def getCurrentTheme(self):
"""The name of the current theme."""
settings = self.getSettings()
if not settings.rules:
return None
if settings.currentTheme:
return settings.currentTheme
# BBB: If currentTheme isn't set, look for a theme with a rules file
# matching that of the current theme
for theme in utils.getAvailableThemes():
if theme.rules == settings.rules:
return theme.__name__
return None
1 Like
espenmn
(Espen)
March 18, 2020, 2:04pm
5
In you manifest.cfg (for the theme) you define the prefix, for example
prefix = /++theme++medialog.dutchestheme
So usually you would set it here and then just use the path /images/image.jpg for you image
So I assume you could do just:
<img src="img/icn/pdf_icn.svg">
1 Like