Dynamic theme.html

Hi.

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

like:

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

And on my manifest.cfg have something like:

[theme:parameters]
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.

Thanks.

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">

  <after
      css:theme-children="html body"
      content="some stuff here"
      />

</rules>

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

Thanks.

Doing what you suggested worked.

:smiley:

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:variable>
<xsl:for-each select="$footer_portlets">
  <div class="col-xs-12 {$columns}">

Plone Foundation Code of Conduct