We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • Quote from: StevenLangbroek at Jul 15, 2010, 08:57 AM

    is this the proper parsing order? I somehow feel like this is a bug, and that the entire content should be parsed before it should be ran through the output-filters...
    The problem is, anything that is non-cacheable cannot be parsed until all cacheable content has been prepared for the cache to be created from. So by default, parsing skips non-cacheable content. This is why I said you would need to use a Snippet to do this and duplicate some of the code in modResponse::outputContent(), because this is the code that is responsible for processing the non-cacheable tags. This, in particular is what I am talking about (lines 60-64 in core/model/modx/modresponse.class.php):
    <?php
                /* collect any uncached element tags in the content and process them */
                $this->modx->getParser();
                $maxIterations= intval($this->modx->getOption('parser_max_iterations', $options, 10));
                $this->modx->parser->processElementTags('', $this->modx->resource->_output, true, false, '[[', ']]', array(), $maxIterations);
                $this->modx->parser->processElementTags('', $this->modx->resource->_output, true, true, '[[', ']]', array(), $maxIterations);
    ?>

    This does two passes of up to 10 iterations each, first processing non-cacheable tags and then processing then again with the option to remove unprocessed tags as it goes.

    But, there are other considerations as well when trying to process content from the page it was intended to run on vs. pulling it in from somewhere else. Registered javascripts, inline javascript, etc. There are a lot of potential problems if you just try to do this. IMO, it’s better to create an already cleansed summary ahead of time, not when a page is being rendered (even if cacheable).
      • 28554
      • 201 Posts
      I understand. So is there an easy way to achieve what I want to do? Or would it always include creation of snippets etc...?
      • Quote from: StevenLangbroek at Jul 16, 2010, 08:30 PM

        I understand. So is there an easy way to achieve what I want to do? Or would it always include creation of snippets etc...?
        Writing a Snippet to do this on render or a Plugin to do it on save should be a fairly easy, one time investment.
          • 28554
          • 201 Posts
          Quote from: OpenGeek at Jul 16, 2010, 09:12 PM

          Quote from: StevenLangbroek at Jul 16, 2010, 08:30 PM

          I understand. So is there an easy way to achieve what I want to do? Or would it always include creation of snippets etc...?
          Writing a Snippet to do this on render or a Plugin to do it on save should be a fairly easy, one time investment.

          Yeah except I’m a front-end developer, can’t write a single line of PHP (except the urlencode-snippet laugh )
            • 3749
            • 24,544 Posts
            You could try calling getResources cached (without the exclamation point), that way it may be parsed before the "If" snippet runs.

            [[getResources ... 



            The alternative would be to fill in the description manually for all problem pages.
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting