<?php
// set menu index
$mnuidx = $modx->db->getValue('SELECT MAX(menuindex)+1 as \'mnuidx\' FROM '.$modx->getFullTableName ('site_content').' WHERE parent=\''.$fields['parent'].'\'');
if($mnuidx<1) $mnuidx = 0;
//or replace $fields['parent'] with a $var/snippet ¶m containg the parent id. Or hard code it
//or use original code $folder and place this in top of snippet:
// $folder = isset($folder) ? intval($folder):$modx->documentIdentifier;
$fields = array(
"pagetitle" => $_POST['title'],
"alias" => $alias,
"content" => "[!MaxiGallery? &manager_webusers=`$webusername` !]",
"published" => 1,
"createdon" => $timestamp,
"richtext" => 0,
"template" => 6,
"parent" => 6,
"menuindex" => $mnuidx
);
working great - thanks! // update the code later

$pagetitle = $modx->db->escape($_POST['title']);
$alias = $modx->stripAlias($pagetitle);
$fields = array(
"pagetitle" => $pagetitle,
"alias" => $alias, ...$pagetitle = $modx->db->escape($modx->stripTags(trim($_POST['title'])));
action="'.$_SERVER['REQUEST_URI'].'"
We should use $modx->db->escape that waythanks, i’ll update the snippet
the code will be much safer.
What is your setup? The form says go here after
creation:
$_SERVER['REQUEST_URI']
