TWIG support for MODX 3

Hi there,
Do you know any workable TWIG solutions for MODX 3? I’ve updated website from 2.8.4 to MODX 3 and it seems used extra modxTwig is no longer supported, I’m looking any other alternatives or way how to update extra up to MODX 3, wonder does it possible at all or some hidden limitations are possible?

I will be grateful for any help, thanks for your time!

I tried to look into it, but I never used modxTwig before.

Is it correct, that the extra phpTemplates also has to be installed for modxTwig to work? If not, how else does modxTwig work?

The extra phpTemplates indeed doesn’t seem to be compatible with MODX 3.

The GitHub page is here, but there hasn’t been a commit in almost 10 years. I couldn’t find any schema files, but the class files and code could probably be updated manually.

Hi @bobray !
Thanks for your input. I remember some your article about old extras adoption for MODX 3, could you please share this link with me, I’ll try and use it for this extra update.

Hi @halftrainedharry,
Well, phpTemplates already installed so it seems you’re right.

The Cheat Sheet is here. It’s the final article in a long series. The rest are spread through the blog, but if you’re familiar with MODX extras, the Cheat Sheet may be enough.

When I replace this code

with this

$tmp = $this->map->offsetGet('MODX\Revolution\modResource');
$tmp['aggregates']['Template'] = array(
    'class' => 'phpTemplate',
    'local' => 'template',
    'foreign'   => 'id',
    'cardinality' => 'one',
    'owner' => 'foreign',
);
$this->map->offsetSet('MODX\Revolution\modResource', $tmp);

it seems to work.


This is of course not a proper rewrite for MODX 3 but may be enough to make the extra run again.

1 Like