Blank page when creating a CMP and no errors on logs

Hey all,

I’m trying create my first CMP without using MIGX and I’m running into this issue. I’m attempting to create a CMP to filter the last orders placed in minishop2 within 24 hours. On the CMP, I will have a single submit button “get results” and it will create a csv/xlsv file with all of those orders.

I was following this tutorial https://docs.modx.com/3.x/en/extending-modx/custom-manager-pages and following steps.

  • create a new namespace called “myshop”
  • set paths to {core_path}components/myshop/ and {assets}components/myshop/
  • create directory “myshop” in components and a directory “controllers” in “myshop”

replaced “namespace” with “myshop” in index & home class.

But I’m getting a blank page and

my code
index.class.php

<?php
/**
 * The main manager controller for myshop.
 *
 * @package myshop
 */

abstract class MyshopManagerController extends modExtraManagerController {
	
	public $myshop;


	public function initialize() {
		
		$this->addHtml('<script type="text/javascript">
        Ext.onReady(function() {
            // We could run some javascript here that runs on all of our controllers
            // for example something that loads your config 
        });
        </script>');

		parent::initialize();
	}


	public function getLanguageTopics() {
		return array('myshop:default');
	}


	public function checkPermissions() {
		return true;
	}
}


class MyshopIndexManagerController extends MyshopManagerController {
	public static function getDefaultController() {
		return 'home';
	}
}

home.class.php

<?php
/**
 * The name of the controller is based on the action (home) and the
 * namespace. This home controller is loaded by default because of
 * our IndexManagerController.
 */
class MyshopHomeManagerController extends MyshopManagerController {
    /**
     * Any specific processing we want to do here. Return a string of html.
     * @param array $scriptProperties
     */
    public function process(array $scriptProperties = array()) {
        return '<h2 class="modx-page-header">It\'s alive!</h2><p>This is your first custom manager page. You are awesome!</p>';
    }
    /**
     * The pagetitle to put in the <title> attribute.
     * @return null|string
     */
    public function getPageTitle() {
        return 'My first CMP!';
    }
    /**
     * Register needed assets. Using this method, it will automagically
     * combine and compress them if that is enabled in system settings.
     */
    public function loadCustomCssJs() {
        $this->addCss('url/to/some/css_file.css');
        $this->addJavascript('url/to/some/javascript.js');
        $this->addLastJavascript('url/to/some/javascript_load_last.js');
        $this->addHtml('<script type="text/javascript">
        Ext.onReady(function() {
            // We could run some javascript here
        });
        </script>');
    }
    
    
}

Anyone can see what I may be doing wrong?

What do you use as the value for “Action:” in the menu item you created?

If it’s home, you probably have to add a require_once line to the file home.class.php, so that the class MyshopManagerController can be found.

require_once dirname(__FILE__) . '/index.class.php';
class MyshopHomeManagerController extends MyshopManagerController {
   ...
}

It seems that the tutorial you linked is somewhat outdated (and the function getDefaultController() not longer used). Maybe use this tutorial instead. (One controller file should be enough to output a single button.)

https://docs.modx.com/current/en/extending-modx/custom-manager-pages/tutorial

I use “index” as my action value. Tried adding the require_once but Im still getting a blank page. I will try the other tutorial.

I don’t see one in your code, but a PHP syntax error in a CMP can give you a blank page with no error message.

Sometimes, you can get a clue to an error by watching the network tab in dev. tools (Ctrl-shift-i) as you launch your CMP.

1 Like