AFAIK, it's not possible in the index.html file. But you can use Diazo:
Define the param portal_url in your manifest.cfg:
[theme]
title = Your Theme
description = A Theme.
preview = preview.png
doctype = <!DOCTYPE html>
[theme:parameters]
portal_url = portal_state/portal_url
You should add a default for portal_url - acting as a fallback - to you root rules.xml file (you never know what users do with the advanced theme settings), so your theme will still work even if the param is removed from the theme:parameters section:
<?xml version="1.0" encoding="UTF-8"?>
<rules xmlns="http://namespaces.plone.org/diazo"
xmlns:css="http://namespaces.plone.org/diazo/css"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xi="http://www.w3.org/2001/XInclude">
<!-- The empty param defined here will be overridden by your manifest.cfg. -->
<xsl:param name="portal_url"></xsl:param>
<!-- Now add your rules ... -->
</rules>
To adjust the html tag in your theme you can use the following rules:
<!-- Copy all attributes from Plone. -->
<copy attributes="*" css:theme="html" css:content="html" />
<!-- Set cache manifest. -->
<before theme-children="html">
<xsl:attribute name="manifest"><xsl:value-of select="$portal_url" />/cache.manifest</xsl:attribute>
</before>
I tested this in one of my themes and the output was:
That is different. You can use the portal_url to adjust the rendered output only, so to define how links to JS, CSS and other resources will look like. What you want to do is adjust the URL for an included document for the XSLT processor.
I tried your example and it did work for me for when accessing it locally. I used that view because it is only available on portal root. Do you have some special settings in your theme which might cause this behaviour?
thanks for your detailed reply thomas. iiuc you're saying that /@@some-view will lead to a request to the plonesite in any case.
maybe my diazo rules are applied to some resource that should be unthemed (some css or whatever) and these requests cause the error...
the xlst:for-each select stuff is a little bit too in-depth for me atm. i'll try this out in my project when time allows it and report back here.
Yes. If you include external content, that content needs to be parsed, processed and than transformed with your rules, just like regular content. So the XSLT preprocessor needs to have the correct URL to that document (using the document function). And adding $portal_url as a prefix to your @href url does not work in that case. It has nothing to do with themed or un-themed content or CSS.
Could you please point to a (minimal) example of a theme that shows the behavior you are describing? Is your theme installed in the file system or uploaded via zip file?
Hello!
I have a question about the diazo rule. I tried to set the portal_url in the head manually. It doesn't work in the main-template (don't ask ). While searching the web for ideas, I found this thread.
I need a <script type="text/javascript"> PORTAL_URL = "https://mysite.de";</script> in the html head, so I tried to put a rule like:
but all I got is:
runtime error, element 'variable' [105:0]
XSLT-variable: Redefinition of variable 'tag_text'. [0:0]
Do you have any ideas for me? I am just a diazo beginner...
The problem is, that I need the quotes before and after the <xsl:value-of select="$portal_url" /> and I can't get it to work.