We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1932
    • 137 Posts
    Not sure if this has been done, but I made a quick modification to eForm to allow parsing via PHx.
    Currently, it will be automatically enabled if you have PHx enabled as a plugin. It could easily be adapted to your specific needs.

    Replace the formMerge(...) function with:

    # Form Merge
    function formMerge($docText, $docFields, $vClasses='') {
    	global $formats;
    	$lastitems;
    	if(!$docText) return '';
    
        if (class_exists('PHxParser')) {
            // Use PHX
    		$phx = new PHxParser(0,500);
            foreach ($docFields as $fieldName => $fieldValue) {
                $phx->setPHxVariable($fieldName, $fieldValue);
            }
    
            $docText = $phx->Parse($docText);
        } else {
            // Use standard replacement
    		preg_match_all('~\[\+(.*?)\+\]~', $docText, $matches);
    		for($i=0;$i<count($matches[1]);$i++) {
    			$name = $matches[1][$i];
    	//mod - splitting name:value to get proper docFields key
    			list($listName,$listValue) = explode(":",$name);
    			$value = isset($docFields[$listName])? $docFields[$listName]:"";
    	//end mod
    
    	// support for multi checkbox, radio and select - Djamoer
    			if(is_array($value)) $value=implode(', ', $value);
    			$fld = $formats[$name];
    			if (!isset($fld)){
    				// listbox, checkbox, radio select
    				$colonPost = strpos($name, ':');
    				$listName = substr($name, 0, $colonPost);
    				$listValue = substr($name, $colonPost+1);
    				$datatype = $formats[$listName][2];
    				if(is_array($docFields[$listName])) {
    					if($datatype=="listbox" && in_array($listValue, $docFields[$listName])) $docText = str_replace("[+$listName:$listValue+]","selected='selected'",$docText);
    					if(($datatype=="checkbox"||$datatype=="radio") && in_array($listValue, $docFields[$listName])) $docText = str_replace("[+$listName:$listValue+]","checked='checked'",$docText);
    				}
    				else {
    					if($datatype=="listbox" && $listValue==$docFields[$listName]) $docText = str_replace("[+$listName:$listValue+]","selected='selected'",$docText);
    					if(($datatype=="checkbox"||$datatype=="radio") && $listValue==$docFields[$listName]) $docText = str_replace("[+$listName:$listValue+]","checked='checked'",$docText);
    				}
    			}
    			if(strpos($name,":")===false) $docText = str_replace("[+$name+]",$value,$docText);
    			else {
    				// this might be a listbox item.
    				// we'll remove this field later
    				$lastitems[count($lastitems)]="[+$name+]";
    			}
    		}
    		$lastitems[count($lastitems)] = "class=\"\""; //removal off empty class attributes
    		$docText = str_replace($lastitems,"",$docText);
    }
    


    This will likely change in the new MODx core, but works well for 0.9.5+.
      • 7455
      • 2,204 Posts
      does this also adres the placeholder in snippet call issue? that phX does not remove the placeholder in eform call like this &from=`[+email+]` &subject=`Reaction from: `[+name+]`

      Dimmy
        follow me on twitter: @dimmy01
        • 8894
        • 114 Posts
        Quote from: Dimmy at Oct 15, 2007, 04:03 PM

        does this also adres the placeholder in snippet call issue? that phX does not remove the placeholder in eform call like this &from=`[+email+]` &subject=`Reaction from: `[+name+]`

        Dimmy
        Do someone have the answer to that question ?
          • 8894
          • 114 Posts
          I gave it a try and the answer is NO.
            • 7455
            • 2,204 Posts
            you could use the mod by pixelshutes thats what I alway’s use:
            http://modxcms.com/forums/index.php/topic,14306.msg104833.html#msg104833

            and made a list that I always use like this:
            # Start processing
            
            include_once ($snipPath."eform.inc.php");
            if( $params[to]{0} == '(' ) $params[to] = str_replace( array('((','))'), array('[+','+]'), $params[to] ); // pixelchutes PHx workaround
            if( $params[from]{0} == '(' ) $params[from] = str_replace( array('((','))'), array('[+','+]'), $params[from] ); // pixelchutes PHx workaround
            if( $params[fromname]{0} == '(' ) $params[fromname] = str_replace( array('((','))'), array('[+','+]'), $params[fromname] ); // pixelchutes PHx workaround
            if( $params[replyto]{0} == '(' ) $params[replyto] = str_replace( array('((','))'), array('[+','+]'), $params[replyto] ); // pixelchutes PHx workaround
            $params[subject] = str_replace( array('((','))'), array('[+','+]'), $params[subject] ); // pixelchutes PHx workaround
            $output = eForm($modx,$params);
            
            # Return
            return $output;
            ?>
            


            so that way you use ((placeholder)) instead of [+placeholder+] (this is only for the snippet call, in the forms you just use [+placeholder+] )

            Dimmy
              follow me on twitter: @dimmy01
              • 8894
              • 114 Posts
              Thank you dimmy but I saw it before your post wink
                • 23491 ☆ A M B ☆
                • 1,056 Posts
                Quote from: Dimmy at Feb 25, 2008, 03:57 AM

                you could use the mod by pixelshutes thats what I alway’s use:
                http://modxcms.com/forums/index.php/topic,14306.msg104833.html#msg104833

                Dimmy

                Hey Dimmy,

                Here’s an update to that eForm mod w/ PHx. Replace existing mod with the following line of code:

                //<?php - for highlighting (do not copy)
                
                foreach( $params as $key=>$val ) $params[ $key ] = str_replace( array('((','))'), array('[+','+]'), $val );  // pixelchutes PHx workaround
                


                This will loop through all parameters and attempt to format as placeholders so as not to conflict with PHx! laugh
                  Mike Reid - www.pixelchutes.com
                  MODx Ambassador / Contributor
                  [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
                  ________________________________
                  Where every pixel matters.
                  • 7455
                  • 2,204 Posts
                  Nice work Mike, thanks
                    follow me on twitter: @dimmy01
                    • 22668
                    • 718 Posts
                    Many Thanks!
                    Phx is a powerful headache grin
                      • 23491 ☆ A M B ☆
                      • 1,056 Posts
                      Quote from: Dimmy at Oct 15, 2007, 04:03 PM

                      does this also adres the placeholder in snippet call issue? that phX does not remove the placeholder in eform call like this &from=`[+email+]` &subject=`Reaction from: [+name+]`

                      Dimmy

                      My updated mod (3 posts up) will also handle this as well! Just drop the placeholder in a similar fashion:

                      &subject=`Reaction from: ((name))`
                      
                        Mike Reid - www.pixelchutes.com
                        MODx Ambassador / Contributor
                        [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
                        ________________________________
                        Where every pixel matters.