Skip to content

Instantly share code, notes, and snippets.

@vgrish
Created February 5, 2016 19:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vgrish/2530a0364bf49b05481f to your computer and use it in GitHub Desktop.
Save vgrish/2530a0364bf49b05481f to your computer and use it in GitHub Desktop.
<?php
echo "<pre>";
$modx->switchContext('web');
$modx->invokeEvent('OnHandleRequest');
if (!$twiggy = $modx->getService('twiggy', 'twiggy', $modx->getOption('twiggy_core_path', null, $modx->getOption('core_path') . 'components/twiggy/') . 'model/twiggy/')) {
return 'Could not load twiggy class!';
}
$tpl = "
{% set q = modx.newQuery('modResource') %}
{% set ok = q.select(['modResource.*']) %}
{% set ok = q.limit('4000') %}
{% set s = q.prepare() %}
{% set ok = s.execute() %}
{% for resource in s.fetchAll(2) %}
<p>{{ resource.id }} - {{ resource.menuindex }} - {{ resource.createdon }} - {{ resource.publishedon }}</p>
{% endfor %}
{{ getInfo() }}
";
$output = $twiggy->process($tpl, array(), false);
print_r($output);
@vgrish
Copy link
Author

vgrish commented Feb 5, 2016

totalTime : 0.1909 s
queryTime : 0.0011 s
phpTime : 0.1898 s
queries : 3
source : cache

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment