Quote from: ambaxter at Apr 17, 2010, 01:04 PM
I have successfully pulled in different data chunks from other contexts in my install. But is there a way to either generate a link directly to another context’s homepage and/or generate a list of all existing contexts?
You could simply use link tags with the actual id of each contexts site_start, use weblinks to create navigation to other contexts from each context, or use something like this (untested):
<?php
$output = array();
$contexts = $modx->getCollectionGraph('modContext', '{"ContextSettings":{}}', array(
'modContext.key:!=' => $modx->context->get('key')
,'modContext.key:!=' => 'mgr'
,'ContextSettings.key' => 'site_start'
));
foreach ($contexts as $context) {
$data = $context->toArray();
if (!empty($context->ContextSettings)) {
$siteStart = reset($context->ContextSettings);
$data = array_merge($data, array('site_start' => $siteStart->get('value')));
}
$output[] = $modx->getChunk($tpl, $data);
}
return implode("\n", $output);
?>
and use a chunk like this for the &tpl:
<li><a href="[[~[[+site_start]]]]" title="[[+description]]" rel="external">[[+key]]</a></li>
I’m also considering adding a new feature to settings placeholders that would allow you to specify the context, e.g.
[[++site_start? &context=`contextA`]]
or a similar mechanism for convenience.