Community

Is there any function to render a modResource from the API?

I found some really old topics around this but nothing directly related. I am looking along the lines of a static site generator for simple sites, where a shared Modx instance is used as the “site creator”. I found the Modx.today article talking about just using file_get_contents on each page URL, but that seems inefficient.

I tried using the process function ($resource->process()), but that didn’t seem to process snippets in the page.

I could probably find the process in the core files, and maybe it’s more complex than I am thinking. It seems like what I am looking for is the equivalent of getChunk but for a full resource.

Thanks!

There is not a function, but you can use a technique like that used in the renderResources extra that is available. The relevant code is viewable at https://github.com/opengeek/renderResources/blob/f5c2d0174e1389811c2208d04f81fa35862699d7/core/components/renderresources/snippet.renderresources.php#L404-L459.

@opengeek Thanks for the quick reply. That should get me what I need. Much appreciated!