As part of a babelisation project, I have to create a new plugin:
<?php
if($modx->context->get('key') != "mgr"){
/* grab the current langauge from the cultureKey request var */
switch ($_REQUEST['cultureKey']) {
case 'en':
/* switch the context */
$modx->switchContext('en');
break;
default:
/* Set the default context here */
$modx->switchContext('web');
break;
}
/* unset GET var to avoid
* appending cultureKey=xy to URLs by other components */
unset($_GET['cultureKey']);
}
linked to System Event OnHandleRequest.
So, I create a new plugin, name it "gateway", copy and paste the code
http://www.class-zec.com/en/blog/2011/seo-friendly-multilingual-websites-with-modx-and-babel.html from the tutorial and save. And it won’t save. A brief flicker of the screen, and nothing happens in the resource tree.
After some investigation and testing (altering an extant plugin worked, as did changing it back), saving another example plugin from the RTFM article on plugins in general terms worked. See:
<?php
$words = array("snippet", "template"); // words to filter
$output = &$modx->resource->_output; // get a reference to the output
$output = str_replace($words,"<b>[filtered]</b>",$output);
But what didn’t work was subsequently replacing the second piece of code with the first. If I do that, the plugin won’t save.
It makes no difference whether or not I create the link to the System Event whether or not the "good" code saves and the "bad" code fails.
I’ve tried washing the cut-and-paste through a text editor. Notepad made no difference, nor did Notepad++. I haven’t yet typed in every character by hand, but I will.
///Now I have typed it allin by hand, all but the documentation, and it works///.
Meanwhile, has anyone else come across this phenomenon? Unsavable plugins?
My set-up
CGI/FastCGI
MODx Revo 2.1.1 (trad)
PHP 5.3.6
MySQL 5.1.56
pdo-mysql installed
ImageMagick 6.4.8 2010-01-07
json version 1.2.1
I browse in Firefox, Safari, IE and Chrome - latest non-Betas of each.
I’m not opcode cacheing to my knowledge