We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 41127
    • 23 Posts
    Is there a way to pre-populate chunks on a event?

    I have a template, chunks, and now i want to create some code that popuplates the chunks so that i can keep everything in 1 file, why i do it this way. I don't want all kind of [[customSnippet? &property=`this`]]. Sure if the way i would like it is not posible i will do it in the snippet way.

    What i was thinking

    <?php
    global $modx;
    
    $currentId = $modx->resource->get('id');
    $objectPageId = 15;
    
    if( $modx->event->name == 'OnWebPagePrerender' && $currentId == $objectPageId )
    {
    	$soapCall = 1;
    	 
    	include(MODX_ASSETS_PATH.'snippets/config.php');
    	include(MODX_ASSETS_PATH.'snippets/functions.php');
    	include(MODX_ASSETS_PATH.'snippets/debug.php');
    	
    	$path = $_GET['q'];
    	$pathPatterns = explode('/', $path);
    	
    	if( !isset( $pathPatterns[2] ) && !is_numeric( $pathPatterns[2] ) ) return '';
    	
    	$currentObject = $pathPatterns[2];
    	
    	$soapObjectParams = array('language' => 'nl');
    	$soapParams = array("user" => $soapUser, "password" => $soapPassword, 'yachtId' => $currentObject, "parameters" => $soapObjectParams);
    	
    	try {
    	
    		$objectArray = unserialize(base64_decode($client->__soapCall('getDetails', $soapParams)));
    	
    	} catch (SoapFault $e) {
    	
    		debugSoap($client);
    	
    	}
    }
    


    Now all that remains is some way to populate the chunks... i know how to do it from a snippet but not from out a plugin.
      • 41127
      • 23 Posts
      Maybe good to know, why i want to do this is that i want to keep the dynamic of quickly changing the order of oure display, but i don't want to make more than 1 soapcall. So i was thinking of creating one file that does a soapcall. Populates chunks and the chunks print the data.