How can i get the current theme

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

Are you looking for something like this?

src="++theme++theme.package/img/icn/pdf_icn.svg"

Yes, but ++theme++theme.package must be the current theme like a variable

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

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