<?php $output = ' <div style="border: 5px solid #49535c; padding: 0px; margin-bottom: 8px; margin-left: 5px; width: 92%; text-align: center; background-color: #fffce6;"> You currently have <a href="[~[+alias:subscription+]~]">no subscription</a> active. </div>'; return $output; ?>
<?php
header("Location: [~[+alias:events+]~]");
?><?php return '<a href="' . $modx->makeUrl($modx->documentListing['subscription']) . '">no subscription</a>'; ?>
<?php
if (!empty($modx->documentListing)) {
foreach ($modx->documentListing as $linkAlias => $linkDocId) {
$modx->setPlaceholder("~{$linkAlias}", "{$linkDocId}");
}
}
?><p> <a href="[~[+~parentalias/alias+]~]">some link I'm creating</a> <a href="[~[+~anotheralias+]~]">another link I'm creating</a> </p>
<?php return '<a href="[~[+alias:subscription+]~]">no subscription</a>'; ?>
<?php
header("Location: ".$modx->makeUrl(0, 'subscription', '', 'full'));
?>
)
Exactly, that’s what placeholders are, though they are also available via API directly (e.g. $modx->getPlaceholder()).
Thanks for the tips OpenGeek. FWIW, it appears that your plugin will work anywhere as long as the final code is passed through the documetn parser.
This is actually incorrect and though it may produce the result you want, that will not work in future releases of MODx. The way I showed in the previous example using $modx->documentListing is the proper way. $modx->makeUrl() should always be used with the document id, and the second parameter is now deprecated (and is reused for other purposes in the upcoming MODx 2.0).
<?php header("Location: ".$modx->makeUrl(0, 'subscription', '', 'full')); ?>
This is actually incorrect and though it may produce the result you want, that will not work in future releases of MODx. The way I showed in the previous example using $modx->documentListing is the proper way. $modx->makeUrl() should always be used with the document id, and the second parameter is now deprecated (and is reused for other purposes in the upcoming MODx 2.0).