It's making me dizzy to think about it.
Here's a snippet that should do the same thing much faster (untested), assuming that I'm understanding your intent. I'm not sure what you want to happen if the conditions are not met:
$r =& $modx->resource;
$url = '';
if ( ($r->get('template') == 58) && ($r->get('context_key') == 'corporate') ){
$suffix = $r->get('isfolder')? '/' : '.html';
$url = $modx->getOption('site_url') . $r->get('alias') . $suffix;
}
return $url;
-
☆ A M B ☆
- 721 Posts
Thanks. Will be able to try later. Don't want it to do anything if the conditions are not met. We may switch to querying the access permission of the document and won't need any combinations, i.e. if editable then use a canonical link specific to the context, if protected, then build a canonical link to the context's parent URL, from which the child contexts gets documents syndicated down to it.
I believe that would be:
(if you're denying it based on the user's Context Access policy)
if ($modx->hasPermission('edit_document') {
/* Editable */
} else {
/* Not Editable */
}
(If you're denying it based on a Resource Group Access policy)
if ($r->checkPolicy('save')) {
/* Editable */
} else {
/* Not Editable */
}