Hi,
I’m trying to set up a collaborative book where there are many sections that a registered user can post to, but only 1 page where the NewsPublisher snippet is called from.
I have an
Add Recipe page which has the following code:
[[SetParentContainerId]]
[+ParentContainerId+]
[[NewsPublisher? &folder=`[+ParentContainerId+]` &canpost=`Recipe Book Admins` &makefolder=`1` &formtpl=`RecipeForm` &rtcontent=`tvRecipeContent` &clearcache=`1`]]
The snippet
SetParentContainerId is defined as:
<?php
$modx->setPlaceholder("ParentContainerId", $_GET['parent']);
?>
Now the link to the Add Recipe page is created with the snippet
AddRecipeLink
<?php
// Usage
//
// &groups = Add the groups which this user should be a member of.
// &parent = The document id of the parent container to add pages to.
if (isset($parent)) {
echo '<p>parent set to: ' . $parent . '</p>';
}else{
echo '<p>parent not set</p>';
return;
}
$groups = isset($groups) ? explode(',', $groups) : array();
for($i = 0; $i < count($groups); $i++) $groups[$i] = trim($groups[$i]);
if ($modx->isMemberOfWebGroup($groups)) {
return '<p><a href="[~18~]' . '?parent=' . $parent . '">Add Recipe</a></p>';
} else {
return '<p>hello 2</p>';
}
return '<p>hello</p>';
?>
and is called in the section container’s like this:
[[AddRecipeLink? &groups=`Recipe Book Admins` &parent=`[*id*]`]]
[[Ditto]]
Now the the parent is set correctly, as the debugging code always dumps the correct value to the page, i.e. id=10 but the newly created page always gets added to the root of the document tree and not the container I’ve specified (10).
N.B. If I specify &folder=`10` in the snippet, it works fine.
Can anybody help with this?
Thanks,
Luke.
P.S: I suppose the easiest route is to just add the NewsPubisher snippet to either each container or create an "Add recipe" page for each container.
P.P.S: Another route and might be preferable would be to be able to specify the folder using a TV in the form.