Override (almost) any core file in Concrete CMS

Jun 8, 2015

When building complex Concrete CMS sites, you may find yourself needing to change some core functionality. Modern versions of concrete offer a few ways that we can do this without sacrificing updatability or performance.

Disable caching

First, turn off overrides caching via Dashboard > System & Settings > Optimization > Cache & Speed Settings. Until this is turned off Concrete CMS won't look in the application directory unless it knows it has a file in there. This will save you from a lot of headaches when developing and testing these overrides.

Service Provider Overrides

Most of concrete's core functionality is bundled into what we call "services", you can find services in subdirectories of the /concrete/src/ directory.
In order to start these services up, concrete employs a pattern known as "Service Provider". A service provider manages booting up a service and adding it onto our Application instance so if we want to modify what a service is doing, this is the place to start.

For example, what if you wanted to swap the core logger with a custom one?

  1. Open up the core app config group, this is located in /concrete/config/app.php
  2. Find where we list "LoggingServiceProvider" and determine the config key. It looks to be app.providers.core_logging
  3. Open up our application's app config group, this is located in /application/config/app.php
  4. Change app.providers.core_logging to our own custom class

In /application/config/app.php:


return array(
    'providers' => array(
        'core_logging' => '\Application\Src\Custom\CustomLoggingServiceProvider'

Now we've overridden the core logging service provider with our own, but the class we offered CustomLoggingServiceProvider doesn't exist since we just made it up.

In /application/src/Custom/CustomLoggingServiceProvider

namespace Application\Src\Custom;

class CustomLoggingServiceProvider extends \Concrete\Core\Service\Provider

    public function register()
        $my_psr3_logger = new \Some\Custom\Logger();

        $this->app->bind('log', $my_psr3_logger);

        // Set the rest of the bindings that the core sets
        $this->app->bind('Concrete\Core\Logging\Logger', 'log');
        $this->app->bind('Psr\Log\LoggerInterface', 'log');


Now instead of the core logging service provider, our own logging service provider is registered and our own custom logger is used everywhere!

Path Based Overrides

Many files can be overridden in concrete simply by providing a file at a specific path. Pretty much the only exclusion to what can be overridden by path is the contents of concrete/src/. Today, we can use paths to override essentially everything that is not a service.

Essentially all path overrides follow an extremely simply pattern: find the path of the file you want to override within the concrete directory, and create a file at that same path within your application directory.

For example:

Core: /concrete/blocks/some_block/view.php
Override: /application/blocks/some_block/view.php

Core: /concrete/js/some_js_file.js
Override: /application/js/some_js_file.js

Overriding Core Block Types

Concrete comes with many useful block types, but sometimes you might want to tweak how a core block functions. Some reasons you might want to override a block include:

  • Override functionality and display
  • Adding a custom template

Override functionality and display

We can add actions, change how things save, and even replace data by overriding a block controller.

For example if we wanted to override the content block to capitalize all content:

In /application/blocks/content/controller.php

namespace Application\Block\Content;

class Controller extends \Concrete\Block\Content\Controller
    public function view()
        $this->set('content', strtoupper($this->getContent()));

That's not all we can override, we can do this same thing with any file in the /concrete/blocks/content/ directory. All you need to do is create the file in your /application/blocks/content/ directory!

Adding a Custom Template

Custom Templates allow us to create custom views for blocks that we can optionally enable.

For example, to modify the HTML block to render as code:

In /application/blocks/html/templates/code_block/view.php

<pre><code><?= h(trim($content)) ?></code></pre>

Custom templates can be used to replace any javascript, css, or view files but they cannot be used to replace the controller.

Path Based Examples

  • Themes
    • Core Path: /concrete/themes/theme_handle/page_theme.php
    • Package Path: /packages/package_handle/themes/theme_handle/page_theme.php
    • Override Path: /application/themes/theme_handle/page_theme.php
    • Override Class Name: \Application\Theme\ThemeHandle\PageTheme
  • Blocks
    • Core Path: /concrete/blocks/block_handle/controller.php
    • Package Path: /packages/package_handle/blocks/block_handle/controller.php
    • Override Path: /application/blocks/block_handle/controller.php
    • Override Class Name: \Application\Block\BlockHandle\Controller
  • Attributes
    • Core Path: /concrete/attributes/attribute_handle/controller.php
    • Package Path: /packages/package_handle/attributes/attribute_handle/controller.php
    • Override Path: /application/attributes/attribute_handle/controller.php
    • Override Class Name: \Application\Attribute\AttributeHandle\Controller
  • Authentication Types
    • Core Path: /concrete/authentication/type_handle/controller.php
    • Package Path: /packages/package_handle/authentication/type_handle/controller.php
    • Override Path: /application/authentication/type_handle/controller.php
    • Override Class Name: \Application\Authentication\TypeHandle\Controller
  • Controllers
    • Core Path: /concrete/controllers/single_page/page_name.php
    • Package Path: /packages/package_handle/controllers/single_page/page_name.php
    • Override Path: /application/controllers/single_page/page_name.php
    • Override Class Name: \Application\Controller\SinglePage\PageName
  • Single Pages
    • Core Path: /concrete/single_pages/account/avatar.php
    • Override Path: /application/single_pages/account/avatar.php
  • Elements
    • Core Path: /concrete/elements/account/menu.php
    • Override Path: /application/elements/account/menu.php
  • Compiled CSS
    • Core Path: /concrete/css/image-editor.css
    • Override Path: /application/css/image-editor.css
  • Compiled JS
    • Core Path: /concrete/js/jquery.js
    • Override Path: /application/js/jquery.js
Recent Tutorials
Add-On Developers: Get Your Add-Ons Ready for Concrete CMS 9.0
Aug 6, 2021
By andrew.

Concrete CMS 9.0 is coming! But there are some changes in version 9 that might affected your add-ons and themes. This document aims to answer questions about the most common ways that your add-ons might need to be changed, and common problems you'll run into.

Permissions for editors in a multilingual site
Jun 2, 2021
By myq_1.

How to set up a multilingual Concrete CMS site for groups of language-specific editors

Getting Started with Doctrine in Concrete CMS
Jan 20, 2021
By linuxoid.

Doctrine is a very flexible, simple (once you get to know it better) and powerful PHP library for database interactions primarily focused on the ORM = Object Relational Mapping and DBAL = DataBase Abstraction Layer.

How To Upgrade PHP Using the MultiPHP Manager In cPanel
Nov 23, 2020

This article will explain how to upgrade your PHP version using cPanel.

How To Add Google Analytics To Your Website - The easy way
Oct 9, 2020

Adding analytics to your website is an important part of running your website. There’s no need to edit your theme or install a plugin to add a tracking code to Concrete CMS you can do it right from the CMS.

How to Generate Sitemap xml File
Oct 9, 2020

Learn how to create a sitemap.xml in a couple clicks

Was this information useful?
Thank you for your feedback.