Diazo using portal url in path in index.html

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:

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" manifest="http://localhost:8080/Plone/cache.manifest" xml:lang="en">

I don't know how the expression portal_state/portal_url behaves with lineage sites.

4 Likes