I tried to use NewsPublisher in a way that a same document including a NewsPublisher snippet could publish in different folders depending on the user who is logged in.
I tried a snippet I called testsnippet:
$username=$modx->getLoginUserName();
switch ($username)
{
case "fr": $folder=11;break;
case "am": $folder=13;break;
default: $folder=0;
}
return $folder;
I tried to imbricate this snippet into NewsPublisher, like this:
[!NewsPublisher? &folder=`[!testsnippet!]` &makefolder=`1` &template=`Minimal Template` &showinmenu=`1` &aliastitle=`0` &formtpl=`fr_newspublisher_blog`!]
However, MODx thinks that the snippets is just [!NewsPublisher? &folder=`[!testsnippet!] and the rest is rendered like text.
Then, I tried to put the php code that returns the $folder variable, like this:
&folder=`$username=$modx->getLoginUserName();switch ($username) { case "fr": $folder=11;break; case "am": $folder=13;break; default: $folder=0; }return $folder;`
Even though I’m logged as fr, the default value of $folder (0) is taken.
So,
1- Is it possible to imbricate snippets? How?
2- Any idea what is going wrong with my code?
Thanks!