I added a new page in this hierarchy: CRM/Mymodule/Page/subdir/MyPage.php and added a template file at templates/CRM/Mymodule/subdir/MyPage.tpl.

But when I run MyPage.php, I get a blank page. Template contents aren't displayed. Adding smartyDebug=1 to the URL doesn't trigger a popup either. Strangely though, if I var_dump a variable, I can see the page with menu bar, page title and the variable info. So MyPage.php is being invoked.

Is it that pages don't support subdirectories? I tried adding the template file using Region. That didn't work either.


I created a page and a corresponding template on CRM/Mymodule/Page/MyPage.php and templates/CRM/Mymodule/MyPage.tpl respectively and manually wrote a route. It didn't work. I then used civix to generate the same page and template. It worked. So, is it compulsory that we create using civix? But I had manually created the form and it had worked.

2 Answers 2


I'd say best to stick with where Civix (aka Tim) says it should go! (i.e. no subdirs) - and note that Civix can help you create the page:


To generate a Page:

me@civisys:/home/me$ cd /var/www/extensions/com.example.myextension
me@civisys:/var/www/extensions/com.example.myextension$ civix generate:page --help
 generate:page className webPath

 className  Page class name (eg "MyPage")
 webPath    The path which maps to this page (eg "civicrm/my-page")

me@civisys:/var/www/extensions/com.example.myextension$ civix generate:page Greeter civicrm/greeter
Write /var/www/extensions/com.example.myextension/xml/Menu/myextension.xml
Write /var/www/extensions/com.example.myextension/CRM/Myextension/Page/Greeter.php
Write /var/www/extensions/com.example.myextension/templates/CRM/Myextension/Page/Greeter.tpl
  • @karing-semper- Is it possible to create subdirs at all? I feel creating subdirs makes it more clean and more readable. Also can you please see the update? Commented Jun 20, 2016 at 17:32
  • I really don't think subdirs are necessary as essentially these Pages are already in subdirectories by extension. When you create the Pages manually - don't forget the class name: example in our iATSAdmin.php: class CRM_iATS_Page_iATSAdmin extends CRM_Core_Page { Commented Jun 20, 2016 at 17:44
  • Civix is not compulsory - but it adds all you need in one command line - I still tend to use it - just b/c it's faster than generating pages (php and tpl) and adding in the class by hand Commented Jun 20, 2016 at 17:46
  • It's indeed faster. I just figured the template wasn't loading because I had omitted parent::run() on the run() method. Thanks. :) Commented Jun 20, 2016 at 18:03

I have set environment to Development and Disabled asset cache at at/civicrm/admin/setting/debug?reset=1 It worked for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.