We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34162
    • 1 Posts
    Hello all ^^,

    I try to make my first plugin but i meet some problems.

    my code : (remake of "Inherit Parent Template")

    
    
    global $content;
    $e = &$modx->Event;
    
    switch($e->name) {
      case 'OnDocFormPrerender':
       	if(($_REQUEST['pid'] > 0) && ($id == 0)) {
    	
    		if	($parent = $modx->getPageInfo($_REQUEST['pid'],0,'template,id')) {
    			
    			if($parent['id']==47){
    			
    				$content['template'] = 5;
    			}elseif($parentparent = $modx->getParent($parent['id'],1,'id')){
    						
    				if ($parentparent['id']==47){
    			
    					$content['template'] = 9;
    				}elseif($parentparentparent = $modx->getParent($parentparent['id'], 1, 'id')){
    					if ($parentparentparent['id']==47){
    					
    					$modx->Event->alert(var_dump($content));
    					
    						$content['template'] = 9;
    								
    						if($test = $modx->getParent($_REQUEST['pid'], 0, 'id')){
    						    $modx->Event->alert($test['id']);
    							$content['parent'] = $test['id'];
    						}
    												
    					} 
    				}	
    				
    			}else{
    				$content['template'] = $parent['template'];
    				//$modx->Event->alert('heritage template normal');
    			}
    		}
    	
        }
        break;
      
    	
      default:
    	return;
        break;
    
    }
    
    


    I try to deny child document creation on a specific document.
    I can’t modify the document parent id.
    Can you help me plz ?

    (sorry for my bad english)