[Solved] Theme fragment disallowed on multilingual site

I use the collective.themefragments addon with a Diazo theme on a multilingual site.

When logged in I get this error with the password change dialog (/@@change-password) :

Couldn't resolve /@@theme-fragment/footer

The same problem occurs with other actions starting with /@@

There's no such issue when using the main language of the web site (en), only with other languages.

What could be the cause?

How did you add the fragment? with diazo?

This could be because the fragment is not present, which might be related to 'the path of the fragment'.

  1. Do you use the same theme for logged in users, and for all languages ?
  2. Do you get a javascript error with an url to the fragment 'that does not exist'?

Yes, Diazo.
Well, not by me, I don't know how to use Diazo, now I'm on my own, trying to understand...

The same theme is used for all languages. The fragment is present, and it's resolved with the main language of the web site, not with other languages.

The error reported by the browser is probably from Diazo, happening before including the footer:

    Tag header invalid [25:40]
    Tag nav invalid [30:56]
    Unexpected end tag : button [54:28]
    Tag section invalid [111:78]
    Tag aside invalid [127:47]
    Tag main invalid [131:48]
    Tag footer invalid [141:36]
    failed to load external entity "/@@theme-fragment/footer" [0:0]

On the console, I get:

2021-09-29 14:37:52,216 ERROR   [plone.subrequest:170][waitress-1] Error handling subrequest to /@@theme-fragment/footer
Traceback (most recent call last):
  File "/home/vagrant/Plone/buildout-cache/eggs/cp37m/Chameleon-3.9.1-py3.7.egg/chameleon/template.py", line 192, in render
    self._render(stream, econtext, rcontext)
  File "/home/vagrant/Plone/zinstance/var/cache/194dae97cf59616569a8ee7f1fbca542.py", line 488, in render
    __cache_140497038150232 = _static_140497147624976('python', "context.toLocalizedTime(now, long_format=0).split(', ')[1]", econtext=econtext)(_static_140497147625032(econtext, __zt_tmp))
  File "/home/vagrant/Plone/buildout-cache/eggs/cp37m/Zope-4.6.3-py3.7.egg/Products/PageTemplates/ZRPythonExpr.py", line 49, in __call__
    return eval(self._code, vars, {})
  File "PythonExpr", line 1, in <module>
  File "/home/vagrant/Plone/buildout-cache/eggs/cp37m/AccessControl-4.3-py3.7-linux-x86_64.egg/AccessControl/ZopeGuards.py", line 109, in guarded_getitem
    v = object[index]
IndexError: list index out of range

I was thinking about the javascript console

PS: I think there could be another reason.
It might be that the problem is not related to theme fragments, but to the code in the fragment itself.

In your theme's fragment folder, there will be a file called 'footer.pt'. Change its content to:

<div><h1>This is a footer</h1></div>

Then restart the site (or disable and enable the theme) and see if you still got an error.

If This is a footer is displayed, there is something wrong with the code in the 'footer'. Maybe you could paste the code of 'footer.pt' (and footer.py if there is one).

That was the issue; there was a TAL expression that was not working for this specific context.

Thanks!