Add-On Developers: Get Your Add-Ons Ready for Concrete CMS 9.0

Aug 6, 2021
Note: this tutorial is a work in progress as new 9.0 issues are reported.

Debug your jQuery

Are you getting strange new JavaScript errors when working with your theme, block or single page? jQuery might be the culprit. Our jQUery in 8.5.5 was very out of date. Version 9 upgrades jQuery to the latest stable (at the time of this document it was 3.6.0.) If you're getting unexplained JavaScript errors, jQuery is the place to start.

$app->make() and Core::make are different now

This one is coming up a lot: if you use Core::make() or $app->make() or $this->app->make() to build a class and pass arguments to that class, you might need to modify this code.

Making a Class with No Arguments Passed at Runtime? No Modifications Needed

Are you building a simple class that might have constructor arguments, but you're not passing custom arguments to it? Something like this?

$object = $this->app->make(MyClass::class);

You don't need to change a thing.

Making a Class with Arguments Passed at Runtime? Check Your Code

If your class constructor takes parameters that you pass at runtime, you might need to modify your code. Consider this class.

<?php

class MyClass
{

    public function __construct($someVariable, $someOtherVariable)
    {
        // ... your code here.
    }

}

If you want to use $app->make() to build this class, while passing in $someVariable, you might have used custom code like this before.

$var1 = 'foo';
$var2 = 'bar';
$object = $this->app->make(MyClass::class, [$var1, $var2]);

This does not work in version 9. The underlying Laravel Container library that powers the Application object no longer works this way. Instead, you have to be explicit about what argument you are setting to what value:

$var1 = 'foo';
$var2 = 'bar';
$object = $this->app->make(MyClass::class, ['someVariable' => $var1, 'someOtherVariable' => $var2]);

In other words, you have to:

  1. check the __constructor method of the class you want to create
  2. take a note of the parameter names
  3. when calling make, use those parameter names (without the leading $) for the kays of the array you use as the second argument

Good news: these modifications are backward compatible with 8.5.5 and earlier.

Theme-level Element Path Changes

Beginning in version 8, we added the ability to override core elements from within your themes. For example, if the core requires an element via View::element(‘conversations/add_post’; the core looks for this add-on in concrete/elements/conversations/add_post.php. However, if the currently active theme provides this element in themes/my_theme/elements/concrete/conversations/add_post.php, it will be used instead. We are changing this to remove the concrete/ directory from the elements directory within your theme. That means in order to override any core element from within your theme, you only need to make it available at the same path within the elements/ directory of your theme.

More Coming Soon

I'll add more to this document as more questions come in through the forums. Please ask questions in the forums in the 9.0.0 release candidate threads and I'll do my best to answer them as quickly as possible!

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.