We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23383
    • 138 Posts
    I don’t know if I’m posting in the right section, but I’m testing PHx on my modx installation, and I’d like to know which code will be parsed faster (I’m a little curious and moreover, with a low performance machine :s)

    Either PHx :
    [*thispageimage:ne=``:then=`<img src="assets/images/pages/[*thispageimage*]" alt="This Page image" width="114px" height="114px" class="left" border="none" />`*]
    

    Or a cached snippet :
    $tv = $modx->getTemplateVar('thispageimage',"", $modx->documentIdentifier);
    if($tv['value']!='')
    {
    return '<img src="assets/images/pages/'.$tv[value].' " alt="This Page image" width="114px" height="114px" class="left" border="none" />';
    }
    

    in my template...
    Does it change something for a page not in cache ? (The little timing tests I’ve done show a little advantage for the cached snippet. Why ?...)
      • 22303 MODX Staff
      • 10,725 Posts
      PHx is an extension to the core parser that brings a lot of additional features, but at a significant performance cost. Snippets on the other hand, especially ones that are cached and don’t get executed on every request, are simply executed very quickly and add little or no overhead to a request.
        • 23383
        • 138 Posts
        Thank you for your fast answer !