minishop2 - Minimum order amount: possible?

Is there a way to set a minimum order amount in minishop2?
I want that customers must reach a minimum amount before they can send a order.

Thank you for your help.
Fabian Christen
21 january 2019, 16:19

pdoResources - using "where" to select a child

Please help me, if possible, to select with pdoResources the resources existent in a specified child of a container.
For example, I have the top level container, named Books and two children Technical and Belletristic. Each of them contain specific books.

I want to display them in two different sections of a page. I think I need something like `where parrent is "%Technical"` but I did not find examples and I need to solve this fast.

Thank you for support!
Claudiu Ro
16 january 2019, 11:35

Minishop2: german umlauts (ä, ö, ü)

When saving a new contact/customer german umlauts (ä, ü, ö) are filtered out.
Can I change this?
Is it in the class
, function
validate($key, $value)

case 'receiver':
                // Transforms string from "nikolaj -  coster--Waldau jr." to "Nikolaj Coster-Waldau Jr."
                $tmp = preg_replace(
                    array('/[^-a-zа-яёЁ\s\.]/iu', '/\s+/', '/\-+/', '/\.+/'),
                    array('', ' ', '-', '.'),
                $tmp = preg_split('/\s/', $tmp, -1, PREG_SPLIT_NO_EMPTY);
                $tmp = array_map(array($this, 'ucfirst'), $tmp);
                $value = preg_replace('/\s+/', ' ', implode(' ', $tmp));
                if (empty($value)) {
                    $value = false;
Thank you for your help.
Fabian Christen
29 june 2018, 13:18

Extra Office: how to save a extended field?

Hi all,

The documentation here explains how to show a extended field of a user.

But how can I save it the first time a user is filling a form?

and in the form:

<input type="text" name="extended[company]" placeholder="" class="form-control" id="" value=""/>

does not work.

Do I have to write a plugin that save this extended field?
Fabian Christen
14 march 2018, 17:19

Error in move_uploaded_file when file uploading

I am using formit to upload image to server and create resource.
In formit2resource, I checked image file was uploaded in formit temp folder.
But, when move file to destination by move_uploaded_file function, an error was occured and temp image in temp folder was not moved.
I am a beginner on MODx, so I hope if someone can help me.

here is my formit2resource code.

$doc = $modx->getObject('modResource',array('id'=>$hook->getValue('resource_id')));
if (empty($doc)){
    $doc = $modx->newObject('modResource');
    $doc->set('createdby', $modx->user->get('id'));
    $doc->set('editedby', $modx->user->get('id'));
$allFormFields = $hook->getValues(); 

 $modx->log(MODx::LOG_LEVEL_ERROR, 'all form fields'.print_r($allFormFields,true));

foreach ($allFormFields as $field=>$value)
   if ($field !== 'spam' && $field !== 'resource_id'){
         $doc->set($field, $value);
$doc->set('template', '1');
foreach ($allFormFields as $field=>$value)
    if ($tv = $modx->getObject('modTemplateVar', array ('name'=>$field)))
        /* handles checkboxes & multiple selects elements */
        if (is_array($value)) {
            $featureInsert = array();
            while (list($featureValue, $featureItem) = each($value)) {
                $featureInsert[count($featureInsert)] = $featureItem;
            $value = implode('||',$featureInsert);
        //$modx->log(MODx::LOG_LEVEL_ERROR, 'array value-'.$doc->get('id').'-'.$value);
        $tv->setValue($doc->get('id'), $value);

//$modx->log(modX::LOG_LEVEL_ERROR,'Start of script-');
// initialize output;
$output = true;
// get the current user name to for dicroty placement
$userName = $modx->user->get('username');
// valid extensions
$ext_array = array('jpg', 'jpeg', 'gif', 'png');
// create unique path for this form submission
$uploadpath = 'assets/userfiles/trash/';
//$uploadpath = 'idt-mdv1-y/assets/images/trash/' . $userName .'/';

// get full path to unique folder
$target_path = $modx->config['base_path'] . $uploadpath;
// get uploaded file names:
$submittedfiles = array_keys($_FILES);

//get exsisting user profile data for Profile_Photos
//$fields = $modx->user->getOne('Profile')->get('extended');
//$Photo_fields = $fields['trashimage'];
// loop through files
foreach ($submittedfiles as $sf) {
    // Get Filename and make sure its good.
    $filename = basename( $_FILES[$sf]['name'] );
    // Get file's extension
    $ext = pathinfo($filename, PATHINFO_EXTENSION);
    $ext = mb_strtolower($ext); // case insensitive
    if($filename != '') {
        // is this the right type of file?
        if(in_array($ext, $ext_array)) {
            //create file called the filename that has been sanitized
            $filename = strtolower(preg_replace("/[^A-Za-z0-9.]+/i", "-", $filename));
            // full path to new file
            $myTarget = $target_path . $filename;
            // temp file name
            $tempname = $_FILES[$sf]['tmp_name'];
            $modx->log(MODx::LOG_LEVEL_ERROR, 'temp name-'.$tempname);
            $modx->log(MODx::LOG_LEVEL_ERROR, 'target path-'.$myTarget);
			//URL path
			$urlPath = $uploadpath . $filename;
            $modx->log(MODx::LOG_LEVEL_ERROR, 'url path-'.$urlPath);
            // create directory to move file into if it doesn't exist
                mkdir($target_path, 0755, true);
                $modx->log(MODx::LOG_LEVEL_ERROR, 'folder create');
            if(file_exists($myTarget)) {
                chmod($myTarget,0755); //Change the file permissions if allowed
                unlink($myTarget); //remove the file
                $modx->log(MODx::LOG_LEVEL_ERROR, 'file delete');
            // is the file moved to the proper folder successfully?
            if(move_uploaded_file($tempname, $myTarget)) {
                 $modx->log(MODx::LOG_LEVEL_ERROR, 'file moved');
                // $hook->setValue($sf, $uploadpath . $filename);
                // $modx->setPlaceholder($sf, $urlPath);
                // place file path to TV
                // if (!$doc->setTVValue($sf, $urlPath)) $modx->log(MODx::LOG_LEVEL_ERROR, 'Upload:Saving TV error');
                $tv = $modx->getObject('modTemplateVar', array ('name'=>'trashimage'));
                $tv->setValue($doc->get('id'), $urlPath);
                // set the permissions on the file
                if (!chmod($myTarget, 0644)) { /*some debug function*/ }  
            } else {
                // File not uploaded
                $errorMsg = 'There was a problem uploading the file.';
                $hook->addError($sf, $errorMsg);
                $output = false; // generate submission error
        else {
            // File type not allowed
            $errorMsg = 'Type of file not allowed.';
            $hook->addError($sf, $errorMsg);
            $output = false; // generate submission error
    } // if no file, don't error, but return blank
    else {
        // is the file name empty (no file uploaded) and exsiting photofields empty
        $hook->setValue($sf, '');
        $hook->addError($sf, 'no file uploaded');
        $doc->setTVValue($sf, '');      // insert empty value to TV


return $output;
10 june 2017, 08:42
1 394

Line break or new line in snippet template?

Hello, maybe it is a strange question, but is there a way to make:

&tpl=`@INLINE <li[[+classes]]><a href="[[+link]]">[[+menutitle]]</a>[[+wrapper]]</li>`
display in html not in one line
but in new lines:

07 march 2016, 16:07
1 838

Modx Multidomain when domains are not aliases


I will write in english, because I don't have russian keyboard, but feel free to reply in russian.

I have domains on one server with the same IP address, but in different directories (virtual domains?):

/same/same/domains/ — modx install here
/same/same/domains/ — copies of .htaccess, index.php and config.core.php here

05 march 2016, 10:14
1 140

Ajaxupload edit - Queue problem

I use a Formit call with some snippets (hooks and prehooks), to give users the ability to upload and edit resources.

Everything working properly except the files upload part. There I use AjaxUpload. The problem is that Ajaxupload when the user logs out, flashes the queue. So, when the user logout and login and try to edit resource, can't see the thumbnails. Data in the field is there but queue is blank.

    &hooks=`AjaxUpload2Formit, formit2resource, redirect`
Poko Loko
17 february 2016, 15:08

Unique number with strtotime

Hi, I would like to create a unique number for each resource I create via a Formit call.

I think the best way is to use a snippet that retrieves current time (with seconds, which is a unique number), that will run as a prehook when the form is loading. Also make a placeholder to use this number in several places inside form.

I am not sure if the code below will give results.

$unique = date('ymdHis',strtotime('NOW'));
$modx->setPlaceholder('time', $unique);
return '';
Poko Loko
16 february 2016, 08:35
1 701

getResources not working properly with snippet

I use getResources along a tpl that includes a snippet. Problem is that getresources gives mixed/wrong results.

My getResource call:
The TPL:
[[!IMAGE_PATH? &docid=`[[+id]]`]]
<div class="dog_cont">
<div class="data_title_new">[[+tv.Race]]</div>
<div class="dog_photo2">
<div id="ad_image_big"><a href="[[!+path1:phpthumbof=`w=900&zc=t`]]" rel="lightbox"><img src="[[!+path1:phpthumbof=`w=200&h=160&zc=t`]]" /></a></div>
<div id="ad_image_small" ><a href="[[!+path2:phpthumbof=`w=900&zc=t`]]" rel="lightbox"><img src="[[!+path2:phpthumbof=`w=95&h=80&zc=t`]]" /></a></div>
<div id="ad_image_small2"><a href="[[!+path3:phpthumbof=`w=900&zc=t`]]" rel="lightbox"><img src="[[!+path3:phpthumbof=`w=95&h=80&zc=t`]]" /></a></div>
$docid = $modx->getOption('docid',$scriptProperties,$modx->resource->get('id'));
if ($resource = $modx->getObject('modResource',$docid)){
    $values = explode(',',$resource->getTVValue('IMAGE'));
    $i = 1;
    foreach ($values as $value){
return '';
Poko Loko
11 february 2016, 23:00
1 510