After upgrading to 2.1 or 2.1.1 I have experienced a couple snippets and packages not working anymore.
The most common one in which I did find the solution was an easy one. It was regarding the popular
Wayfinder package.
After upgrading, my site shot an error on crashed my homepage due the use. After I re-downloaded, uninstalled the old and installed the latest package via the Package Management section. Issue fixed. Wayfinder working again.
SOLUTION: For existing packages you have installed, after the upgrade make sure to download the latest versions and update all other and clear your cache.
Other issues may not be so easy. And I need help on this one:
Last time I upgraded MODx it was to 2.0.4. I remember that certain syntax regarding placeholders had been changed. In regard to the snippet that no longer works, NavigateSiblings,
http://modxcms.com/forums/index.php/topic,4847.0.html
I had updated the placeholder syntax where it was working fine with the newer 2.0.4 installation.
Yet, now, after upgrading to 2.1.1, it no longer works?
I still have to familiarize myself with MODx markup, it’s been awhile but logically, it’s a simple snippet and unless some syntax has been changed again, I’m not understanding why this no longer works.
NOTE: If you look at the actual snippet use as documented in the NavigateSiblings post above, the syntax i actually use is updated to work with 2.0.4.
Here’s the actual snippets, followed by the chunks, followed by the usage in a template that i had implemented
worked fine in 2.0.4 and no longer works after upgrading to 2.1.1:
NavigateSiblings (Snippet)
<?php
/**
* NavigateSiblings
*
* Flexible prev/next/parent navigation for a document with siblings. You can
* use it to output templated links, or just set placeholders
*
* @author Jason Coward, <[email protected]>.
* @version 1.0
*
* Example usage:
*
*
* [!NavigateSiblings? &mode=`direct`!] -- returns the output directly in place
* of the snippet; it is assumed you are using chunk templates for this mode.
* This is also the default mode if not specified.
*
* [!NavigateSiblings? &mode=`template`!] -- sets placeholders using template
* mode by using the default template chunk names, prevSibling, nextSibling, and
* navSiblingsParent, and producing output to placeholders of the same name as
* the chunk: navSiblingsPrev, navSiblingsNext, and navSiblingsParent.
*
* [!NavigateSiblings? &mode=`urlonly`!] -- no output is returned, and
* no templates are processed; instead, the snippet only sets the values of
* placeholders for each link URL: prevSiblingUrl, nextSiblingUrl, and
* navSiblingParentUrl.
*/
/*
* Define the mode of the snippet:
*
* &mode=`template` -- will produce placeholders containing templates within
* which the URL placeholders can be used (default mode).
*
* &mode=`direct` -- will output the template chunks in the place where the
* snippet is called within your content.
*
* &mode=`urlonly` -- will only produce placeholders for the navigation URLs.
*
*/
if (!isset ($mode) || ($mode !== 'template') || $mode !== 'urlonly') {
$mode= 'direct';
}
/*
* Define a chunk representing the presentation of the previous sibling link.
* &prevChunk=`myPrevSiblingChunkName`
*/
if (!isset ($prevChunk)) {
$prevChunk= 'prevSibling';
}
/*
* Define a chunk representing the presentation of the next sibling link.
* &nextChunk=`myNextSiblingChunkName`
*/
if (!isset ($nextChunk)) {
$nextChunk= 'nextSibling';
}
/*
* Determine whether or not to show a link back to the parent.
* &showParent=`0` -- will disable this, which is set to 1 by default.
*/
if (!isset ($showParent)) {
$showParent= 1;
}
/*
* Define a chunk representing the presentation of the parent link.
* &parentChunk=`myNavParentChunkName`
*/
if (!isset ($parentChunk)) {
$parentChunk= 'navSiblingsParent';
}
$output= '';
$prevOut= '';
$parentOut= '';
$nextOut= '';
$parentId= (string) $modx->documentObject['parent'];
if (!function_exists('filterNonSiblingsFromDocumentMap')) {
function filterNonSiblingsFromDocumentMap($var) {
global $modx;
return (isset ($var[$modx->documentObject['parent']]));
}
}
$siblings= array_filter($modx->documentMap, 'filterNonSiblingsFromDocumentMap');
$currentKey= false;
$prevSibling= false;
$nextSibling= false;
$firstSibling= current($siblings);
$currentSibling= $firstSibling;
while ($currentSibling !== false) {
if (intval($currentSibling[$parentId]) === intval($modx->documentIdentifier)) {
$currentKey= key($siblings);
break;
}
$currentSibling= next($siblings);
}
$lastSibling= end($siblings);
if ($currentKey) {
if (intval($firstSibling[$parentId]) !== intval($modx->documentIdentifier)) {
$modx->setPlaceholder('prevSiblingUrl', $modx->makeUrl($siblings[$currentKey - 1][$parentId]));
$prevOut= !empty ($prevChunk) ? $modx->getChunk($prevChunk) : '';
}
if ($showParent) {
$modx->setPlaceholder('navSiblingParentUrl', $modx->makeUrl($parentId));
$parentOut= !empty ($parentChunk) ? $modx->getChunk($parentChunk) : '';
}
if (intval($lastSibling[$parentId]) !== intval($modx->documentIdentifier)) {
$modx->setPlaceholder('nextSiblingUrl', $modx->makeUrl($siblings[$currentKey + 1][$parentId]));
$nextOut= !empty ($nextChunk) ? $modx->getChunk($nextChunk) : '';
}
}
if ($mode == 'template') {
if (!empty ($prevChunk)) {
$this->setPlaceholder($prevChunk, $prevOut);
}
if (!empty ($nextChunk)) {
$this->setPlaceholder($nextChunk, $nextOut);
}
if (!empty ($parentChunk)) {
$this->setPlaceholder($parentChunk, $parentOut);
}
} elseif ($mode == 'direct') {
$output.= $prevOut . "\n";
$output.= $parentOut . "\n";
$output.= $nextOut . "\n";
}
return $output;
Chunk example: nextSibling (Chunk)
<a href="[[+nextSiblingUrl]]" title="Next page">NEXT PAGE</a>
In a page template (Template)
<div id='siblingnav'>[[NavigateSiblings? &mode=`template`]]</div>
OK, so my questions are using this example:
1) Has any syntax changed since v2.0.4 and if so what has changed in regard to the above example and why it no longer works?
2) Could someone point me to a guide to current MODx syntax, preferably a compiled guide, pdf, etc for reference?
3) A simple explanation why the above doesn’t work or if I missed something that I needed to do after the upgrade regarding my snippets.
4) Lastly, is there an up-to-date resource (outside of other 3rd party sites, but suggestions for free resources are welcome) that has a directory of working snippets for the latest, up-to-date MODx version?
For packages, you need to either download or update or even re-install, so I am assuming something syntactically need to be changed in old snippets now?
Thanks for any help.