We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42524
    • 12 Posts
    I'm having a weird problem which i can't seem to solve. When i'm using Modx Cloud my custom build components code is being echoed instead of parsed. This only happens when i'm using Modx Cloud, i've tested this on my localhost (mamp) and a one.com hosting and on both the code is being parsed like i would expect.

    The code i use to test should write its config settings to the log, which does happens on my none cloud servers. On several modx cloud servers the following output is echoed.

    I believe i'm missing some sort of system setting but can't figure it out, does any one know the answer or point me in the right direction?

    Server details
    Localhost server runs
    modx revo 2.2.14
    PHP 5.4.10
    No add-ons

    One.com server runs
    modx revo 2.2.7 (yes, i should update this one)
    PHP 5.3.28
    A lot of add-ons

    Modx Cloud runs
    modx revo 2.2.14
    PHP 5.4.27
    No add-ons

    The output

    modx =& $modx; $corePath = $this->modx->getOption('demo.core_path',null,MODX_CORE_PATH.'components/demo/'); $assetsPath = $this->modx->getOption('demo.assets_path',null,MODX_ASSETS_PATH.'components/demo/'); //Add extra config values $this->config = array_merge(array( 'package_name' => 'Demo', 'core_path' => $corePath, 'asset_path' => $assetsPath, ), $config); $this->modx->addPackage('demo', $this->config['core_path'].'model/'); } public function initialize() { $this->config = array_merge(array( /** Add extra config values */ ), $this->config); } public function configInformation() { /** Log the config settings */ $this->modx->log(modX::LOG_LEVEL_ERROR, print_r($this->config ,true)); } public function output($output) { /** Output and maybe some output filtering */ return $output; } }


    I'm using a snippet called demo with the following code
    require_once($modx->getOption('demo.core_path',null,$modx->getOption('core_path',null,MODX_CORE_PATH).'components/demo/').'model/demo/demo.class.php');
    $demo = new Demo($modx,$scriptProperties);
    $demo->initialize();
    $demo->configInformation();
    


    The demo class code
    <?
    /**
     * The base class for Demo.
     *
     * @package demo
     */
    class Demo {
    	/**
    	 * A reference to the modX instance
    	 * @var modX $modx
    	 */
    	public $modx;
    	/**
    	 * A configuration array
    	 * @var array $config
    	 */
    	public $config;
    	
    	function __construct(modX &$modx,array $config = array()) {
    		$this->modx =& $modx;
    		$corePath = $this->modx->getOption('demo.core_path',null,MODX_CORE_PATH.'components/demo/');
    		$assetsPath = $this->modx->getOption('demo.assets_path',null,MODX_ASSETS_PATH.'components/demo/');
    		
    		//Add extra config values
    		$this->config = array_merge(array(
    			'package_name'	=> 'Demo',
    			'core_path'		=> $corePath,
    			'asset_path'	=> $assetsPath,
    		), $config);
    		
    		$this->modx->addPackage('demo', $this->config['core_path'].'model/');
    	}
    	
    	public function initialize()
    	{
    		//$this->config = array_merge(array(), $this->config);
    	}
    	
    	public function configInformation()
    	{
    		$this->modx->log(modX::LOG_LEVEL_ERROR, print_r($this->config ,true));
    	}
    }
    

    This question has been answered by Bruno17. See the first response.

    • discuss.answer
      • 4172
      • 5,888 Posts
      you're using short open tags.
      This may be your issue.

      http://www.php.net/manual/en/language.basic-syntax.phptags.php

      <?php
      /**
       * The base class for Demo.
       *
       * @package demo
       */
      class Demo {


        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 42524
        • 12 Posts
        Quote from: Bruno17 at May 10, 2014, 03:09 PM
        you're using short open tags.
        This may be your issue.

        http://www.php.net/manual/en/language.basic-syntax.phptags.php

        <?php
        /**
         * The base class for Demo.
         *
         * @package demo
         */
        class Demo {


        Yes this worked, thank you very much! You just saved me tons of work looking in the wrong places.