Lexicon tags and caching

I have a question regarding the functionality of lexicon tags. I just stumbled upon a case where my lexicon tags were not loading at all while using the Login extra.

I have a chunk containing a register form and it’s called cached: [[$register.form]]
(Below the register snippet which is called uncached: [[!Register?... ]] but I don’t think this matters.)

Now when viewing the form in the frontend the lexicon tags inside the form chunk like [[%register.fullname]], [[%register.email]], [[%register.password]], etc. were not loading their corresponding values but were just displaying their tag names.

When I tried calling the form chunk uncached [[!$register.form]] they loaded just fine. Why would they need to be called uncached?


A slightly different case is a lexicon tag from Commerce that I used inside the chunk for the Login form. When I save this chunk and view the Login form in the frontend, the tag is displayed fine, but after a reload of the page it also just displays the tag name.

So it somehow needs the cache to be cleared (which happens when saving the chunk) to display, but after the initial load it’s cached again and therefore not displaying. Interestingly enough it doesn’t matter if I call the tag uncached, it still depends on the chunk. And I can’t call that uncached as it’s referenced as a property by the Login snippet &loginTpl.

Can someone shed some light here?

MODX 2.8.5
PHP 8.2

Does it work correctly, if you add the namespace and topic properties to the lexicon tags? (At least for the first one!)

[[%register.fullname? &namespace=`login` &topic=`register`]]

This worked in both cases!

Can you explain, why that would be needed, though?

Lexicon files don’t get automatically loaded.

When you just have a lexicon tag ([[%...]]) without topic or namespace, the code assumes it’s in the “core” namespace and the “default” topic.

The code may find the tag nevertheless, but only if the lexicon file was loaded beforehand. For example by a snippet or a plugin.

1 Like

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.