Questions

Using a migx tv to filter with msproducts

Hello,

I am currently developing an e-commerce multi site. I need to filter out products base on its territory. To filter out products, I have created a migx tv named product_prices which has a listbox tv that contain all of the territories where the product maybe available e.g country 1==c1||country 2 ==c2||country 3 ==c3, etc. Also I have 2 date tvs, Deal start date & Deal end date (with date and time options) within this migx, so I can filter out special deal products when a territory has a promotion. I've tried using the code below but nothing happens
[[!msProducts?
    &parents=`[[*id]]`
    &paginator=`pdoPageWrapper@naturesdiscount`
    &element=`msProducts`
    &class=`msProduct`
    &sortold=`ms|price:desc`
    &sort=`resource|menuindex:asc`
    &limit=`3`
    &tplOuter=`nd.tpl.mFilter2.outer`
    &tpl=`nd.tpl.msProducts.row`
    &tplFirst=`nd.Firsttpl.msProducts.row` 
    &tpl_n3=`nd.Thirdtpl.msProducts.row` 
    &tplLast=`nd.Lasttpl.msProducts.row`
Jevon Boyce
03 june 2019, 23:22
27
0

Minishop2 and Office: additional fields (gender, building, fullname)

Dear MODX Community,

I some questions about using fields in minishop2 with the Extra «Office».

1. user field «gender»
I added a select field for the gender of a customer. I want to use it for the salutation (Mr. / Ms.).
It works within the Office form chunk (tpl.Office.Profile.form)
<!-- gender: {$gender} -->
    <div class="form-group">
        <label class="col-md-2 control-label" for="gender">Anrede</label>
        <div class="col-md-2">
            <select class="form-control" name="gender" id="gender">
              <option value="0">-- Anrede --</option>
              <option value="2" {if $gender == "2" }selected{/if}>Frau</option>
              <option value="1"{if $gender == "1" }selected{/if}>Herr</option>
            </select>
        </div>
    </div>
    <!-- end gender -->
But on registration (in the chunk «tpl.Office.auth.login» it does not save the gender. How do I activate it?

2. Gender in a order of minishop2
How can I add the field «gender» (see above) in the address fields in a order? Chunk «tpl.msOrder».

3. Email addresses with errors
Sometimes new customers do write their email address with errors. Is there a way to add a second field for the email address where they have to enter the email address again to verify it?

thank you for your help.
Fabian
Fabian Christen
03 june 2019, 13:23
1
29
+1

Using pdoPage pagination placeholders

Hello,

Is it possible to show «Showing 1 to 5 of 15 (3 Pages)», «Showing 6 to 10 of 15 (3 Pages)», «Showing 11 to 15 of 15 (3 Pages)»,...etc with pdoPage? is there a placeholder for firstItem and lastitem? I have been searching online but I cannot find any solution to my question.
Jevon Boyce
26 may 2019, 01:13
34
0

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
Fabian Christen
21 january 2019, 16:19
99
0

pdoResources - using "where" to select a child

Hello!
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
100
0

Minishop2: german umlauts (ä, ö, ü)

When saving a new contact/customer german umlauts (ä, ü, ö) are filtered out.
Can I change this?
Is it in the class
msorderhandler
, 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('', ' ', '-', '.'),
                    $value
                );
                $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;
                }
                break;
Thank you for your help.
Fabian Christen
29 june 2018, 13:18
337
0

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?

[[!Office?
            	&action=`Auth`
            	&groups=`Customers`
            	&loginResourceId=`3`
            	&logoutResourceId=`22`
            	&HybridAuth=`0`
            	&profileFields=`username:50,email:50,fullname:50,mobilephone:12,address:20,city,zip,extended[company]`
            	&tplLogin=`shop.Office.auth.login`
            	&tplRegister=`shop.Office.auth.register`
            	&tplLogout=`shop.Office.auth.logout`
            	&tplActivate=`shop.Office.auth.activate`
            	&loginResourceId=`45`
            	
            ]]
and in the form:

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

does not work.

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

Error in move_uploaded_file when file uploading

Hello
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.

<?php
$doc = $modx->getObject('modResource',array('id'=>$hook->getValue('resource_id')));
 
if (empty($doc)){
    $doc = $modx->newObject('modResource');
    $doc->set('createdby', $modx->user->get('id'));
}
else{
    $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');
$doc->save();
 
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);
        $tv->save();
    }
}
 

//$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
            if(!is_dir($target_path)){
                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);
                $tv->save();
                
                // 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
    }
}

$doc->save();

return $output;
dfXie
10 june 2017, 08:42
1 674
0

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
<li></li><li></li><li></li>
but in new lines:
<li></li>
<li></li>
?

Thanks!
Trying
07 march 2016, 16:07
2 155
0

Modx Multidomain when domains are not aliases

Hello,

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/maindomain.com/public_html/ — modx install here
/same/same/domains/domain2.com/public_html/ — copies of .htaccess, index.php and config.core.php here
etc

Trying
05 march 2016, 10:14
1 306
0