Concrete 5.7 : creating a PageTheme class for a package’s Theme

Concrete 5.7 is completely different compared to 5.6. One of the many new features is the usage of a PageTheme class in themes. Previously themes didn’t have such as class. A PageTheme class is kind of what a controller is for a package.

A PageTheme class is optional for themes, which means a theme will install without it. But having a PageTheme class gives you more control over your theme. You can define custom css classes for your blocks here for example as well as load Javascript and CSS assets you need in your theme.

Documentation is still in the early stages when it comes to Concrete 5.7. Creating a PageTheme class is easy but getting it to work can be tricky if you don’t know how. I could find documentation on creating one in the application/themes folder but not for creating one in a theme contained in a package.

So here’s how to install a PageTheme class for your custom package.

Let’s say your package’s name is ‘MyAwesomePackage’ and you have a theme in this package called ‘MyAwesomeTheme’ . Your package’s handle will then be ‘my_awesome_package’ and the handle for this theme will be ‘my_awesome_theme’. In that theme you will have a class called ‘PageTheme’ and the filename will be ‘page_theme.php’.

This is wat your directory structure will look like so far :

– /packages/my_awesome_package
    – /themes/my_awesome_theme
        – /page_theme.php

Then you will need to namespace your theme; in this case the namespace will be : Concrete\Package\MyAwesomePackage\Theme\MyAwesomeTheme

In code :

Another important thing : If you add this after you installed your theme you will have to trigger detection for this class as Concrete will otherwise ignore it if it wasn’t present when the theme was installed. There are two ways to do this:

1.) Activate another theme, then reactive your theme.
2.) Alter the record in the table ‘PageThemes’ of your database and set the value of column ‘pThemeHasCustomClass’ to ‘1’ in the record belonging to your theme.

The last one is easier and safer to do I think because switching themes might break things but that’s just a guess.

That’s all folks! Happy coding!

Published by



Hi there! I'm a software engineer currently employed at a company in The Hague in the Netherlands. You can find out more about me and my qualifications on LinkedIn ( I started this blog in order to share interesting code snippets and tutorials on mainly Javascript, PHP and related frameworks. The internet is an invaluable resource for programmers and unfortunately there's never enough documentation out there. So this is me trying to contribute to that.

Leave a Reply