Error Theme Inherited from Barceloneta footer_portlets_count

Hi!

I am trying to theme Plone following https://training.plone.org/5/theming/ttw-advanced-2.html

After creating a new theme that inherits from Barceloneta, I am getting the following error after reloading the home page of the site:

runtime error, element 'if' [148:0]
Variable 'footer_portlets_count' has not been declared. [0:0]
Undefined variable [0:0]

The rules xml displayed after the above three lines that include the string footer_portlets_count are the following:

<xsl:variable name="footer_portlets_count" select="count($footer_portlets)"/>

after "Footer" section

and

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

after "Move all other footer portlets into doormat area." section

I think all these come from Barceloneta.

Any ideas?

Thanks.

Filipe

I use the following for the replacement:

<!-- Central column with Right Portlets if available -->
<replace css:theme=".content-container" method="raw">
  
  <xsl:variable name="central">                
    <xsl:if test="//aside[@id='portal-column-two']">col-md-9</xsl:if>                
    <xsl:if test="not(//aside[@id='portal-column-two'])">col-md-12</xsl:if>
  </xsl:variable>
    
  <xsl:variable name="right">
    <xsl:if test="//aside[@id='portal-column-two']">col-md-3</xsl:if>
    <xsl:if test="not(//aside[@id='portal-column-two'])">col-md-6</xsl:if>
  </xsl:variable>
    
  <div class="container content-container">
    <div class="row">
      <!-- Main Content -->
      <div class="{$central}">
        <!--- ..... -->
      </div>
      <!-- /Main Content -->
      
      <!-- Right Slot -->
      <div class="{$right}">
        <!--- ..... -->
      </div>
      <!-- /Right Slot -->
    </div>
  </div>
</replace>

I have never seen the 'count'… is it documented somewhere ?
What happens if you declare the variable as:

<xsl:variable name="footer_portlets_count">3</xsl:variable>

Completely unrelated, but you could consider using CSS flex or CSS grid and do it all with CSS (that is what I do)

If i see correctly the $footer_portlets variable is missing .... see the rules.xml on barceloneta master here https://github.com/plone/plonetheme.barceloneta/blob/master/plonetheme/barceloneta/theme/rules.xml#L104-L175

I just ran into this issue and solved it as follows:

  1. replace the filesystem barceloneta theme with a TTW version
  2. in the ttw version, find rules.xml and cut out the section marked with <!-- Footer --> in lines 104-107
  3. paste the two xsl variable definitions footer_portlets and footer_portlets_count below the line <replace css:theme-children="#portal-footer .doormat"> near line 126
  4. rename index.html in your custom theme to theme-index.html
  5. copy index.html from barceloneta to index.html in your custom theme
  6. use the following rules.xml
<?xml version="1.0" encoding="UTF-8"?>
<rules xmlns="http://namespaces.plone.org/diazo"
		xmlns:css="http://namespaces.plone.org/diazo/css"
		xmlns:xhtml="http://www.w3.org/1999/xhtml"
		xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
		xmlns:xi="http://www.w3.org/2001/XInclude">
  <rules css:if-content="body:not(.userrole-anonymous)">
    <!-- Import Barceloneta rules -->
    <xi:include href="++theme++barceloneta/rules.xml"
		/>
    <after css:theme-children="head">
      <link rel="stylesheet"
		href="/++theme++barceloneta/less/barceloneta-compiled.css"
		/>
    </after>
  </rules>
  <rules css:if-content="body.userrole-anonymous">
    <theme href="theme-index.html"
		/>
    <!-- your customizations go here -->
  </rules>
</rules>

Note: on Plone 5.2 RC4 you will run into this issue when overriding barceloneta: https://github.com/plone/plone.app.theming/issues/160

Plone Foundation Code of Conduct