How can I pass a session variable into a snippet as a parameter?
I am trying to set up a single page to handle the creation of content in a section where the front end user can create (nested) child documents to whatever degree she wants. Ideally she (my wife) can browse to a document (photo gallery), and from there create a child document under it.
At this point I’ve hit a brick wall. I have a link which generates a session variable called "folder" (real creative, I know), then launches the gallery creator page. The page contains only the following uncached call to NewsPublisher:
NewsPublisher?
&folder=`{{GetFolder}}`
&canpost=`Blog Admins`
&formtp=`blogForm`
&footertpl=`FormGallery`
&makefolder=`1`
&clearcache=`1`
&showinmenu=`1`
The chunk {{GetFolder}} calls the following snippet of the same name:
session_start();
$id = $modx->documentIdentifier;
$pid = $modx->getParent($id,1,'id');
return isset($_SESSION['folder']) ? intval($_SESSION['folder']):$pid['id'];
If I show the text used in the snippet call (without the [! ) everything appears as it should, with the calling page set as the folder parameter. However, when I create a post with the form, the new item is created under the creator document - as though the folder variable was never set in the call!
I have been wrestling with this for the last week, and can’t figure out where I am wrong in this. Perhaps it is my approaching? If you have a viable alternative, please let me know. I’m am very perplexed by this! Thanks!
matt