Dynamic theme.html


It's possible to put dynamic content in theme.html


<div if="$my_option"> render this</div>

And on my manifest.cfg have something like:

my_option = myClass/myMethod

If this it's not possible can someone point me to a documentation page where I can achieve something similar.

What I want to do is, function will make a request to some server, see if can put that content there, if can will get the content from that request and a lot of configurations and put the content on the page.


I think (but I am not sure) that you can not do that.
What you can do is to load / insert a template from rules.xml and then use TAL in that template.
Another options could be to have a condition in rules, something like:

<rules if="$my_option">

      css:theme-children="html body"
      content="some stuff here"


That said: I dont think you use dynamic variables in manifest (not sure here too).

I think the easiest is to put all the conditions in a template file. I use something similar:

  <after css:theme="body" css:content="#customcss"  href="/@@theme-fragment/customcss"  />

and in my fragments/customcss.pt I have

 <style tal:condition="view/editmode">stuff here</style>

and in customcss.py I have

def editmode(self):
    if  'disabled' in self.data:
        return True
    return False


Doing what you suggested worked.


the rules.xml, to manage the footer column number, uses this:

<xsl:variable name="columns">
  <xsl:if test="$footer_portlets_count=1">col-md-12</xsl:if>
  <xsl:if test="$footer_portlets_count=2">col-md-6</xsl:if>
  <xsl:if test="$footer_portlets_count=3">col-md-4</xsl:if>
  <xsl:if test="$footer_portlets_count=4">col-md-3</xsl:if>
  <xsl:if test="$footer_portlets_count>4">col-md-4</xsl:if>
<xsl:for-each select="$footer_portlets">
  <div class="col-xs-12 {$columns}">

Plone Foundation Code of Conduct