Lingua and renderResources

On a site I am working on, we have Lingua and we have some processes that use the renderResources extra. They don’t work perfectly together, specifically related to standard placeholders like [[*pagetitle]].

Rendering a page with its standard template, the [[*pagetitle]] is correctly substituted with the language-appropriate page title. However, using renderResources, the [[*pagetitle]] placeholder renders in English instead of in the desired language. The [[*content]] placeholder is rendering correctly.

It’s possible (but not guaranteed) that I am somehow doing something in my code before calling renderResources to cause the problem, but I haven’t been able to locate the issue.

After going through both the MODX and the Lingua code, I can’t figure out how Lingua is causing [[*pagetitle]] to render correctly in the normal case, so I can’t troubleshoot effectively.

Any thoughts, tips, advice?

You probably have to use [[!lingua.getValue? &field=`pagetitle`]] in your template (instead of [[*pagetitle]]) to make it work.


The snippet renderResources reads the data from the normal database table modx_site_content but Lingua saves the versions for the additional languages to modx_lingua_site_content.

I did see that in the documentation and that might be the only solution, but that doesn’t explain what is happening. Viewing the page on the web, [[*pagetitle]] is enough and Lingua (somehow) makes that work. But it doesn’t work through renderResources. I have tried to figure out where the difference is between the two methods, but I haven’t figured out how Lingua is working in the web instance, so it makes it hard to compare accurately with renderResources.

I suspect that it has something to do with the call to $modx->resource->process(), but I’m not certain.

I don’t think so. As far as I know Lingua doesn’t change the class modResource.

But Lingua extends the class modRequest

class LinguaRequest extends modRequest {

Then changes the values of the resource there and manages its own cache for the different language versions.

I did see that and I do have the custom system setting to use LinguaRequest. I guess renderResources doesn’t use modRequest/LinguaRequest to do any of its work. It would be more straightforward (in this case) if it did. I wonder if there’s a way to use the LinguaRequest functionality without an actual web request. Probably not.

Is probably easier to modify/expand the renderResources snippet to also query linguaSiteContent (and linguaSiteTmplvarContentvalues) depending on the current language.