Hi - To speed up our site (on first load after cache refresh) I'm writing the output of wayfinder into a chunk - the idea is when you clear the cache it writes the chunk.
I wrote an isolated PHP file to do this and it works perfectly - but when I throw the code into a plugin - wayfinder doesn't seem to output anything - i.e. returns an empty string. The custom plugin itself seems to run fine.
The original PHP file had this at the top:
<?php
require_once '/home/lnx6equi/www/config.core.php';
require_once MODX_CORE_PATH.'model/modx/modx.class.php';
$modx = new modX();
I assume this isn't needed in the plugin as it's already initialized - below follows what I've put into the plugin window:
<?php
// perhaps this stuff isn't needed either?
$modx->initialize('web');
$modx->getService('error','error.modError');
$siteStartId = $modx->getOption('site_start');
$modx->resource = $modx->getObject('modResource',$modx->getOption('site_start'));
$modx->user = $modx->getObject('modUser',1);
$myChunk = 'fastermenu'; // define chunk to write to
$params['startId'] = '0';
$params['level'] = '2';
$params['innerTpl'] = 'MAINNAV_NavInner';
$params['rowTpl'] = 'MAINNAV_NavRow';
$params['innerRowTpl'] = 'MAINNAV_NavInnerRow';
$params['startItemTpl'] = 'MAINNAV_NavRow';
$html = $modx->runSnippet('Wayfinder', $params); //$HTML seems empty?
$chunk = $modx->getObject('modChunk', array('name' => $myChunk));
if (!empty($chunk)) {
$chunk->setContent($html);
$chunk->save();
}
If I pass "debug=1" into the params - wayfinder returns "
No resources found for menu". It's as though it's ignoring the startid param.
Any tips would be helpful!
thanks,
Tim.
[ed. note: timmyh last edited this post 14 years ago.]