Conversation Block in Custom Theme Showing Error

I am trying to get a Conversation block working with my custom theme. The error I am receiving is Uncaught TypeError: e.dropdown.handle.dropdown is not a function. The error does NOT show when I am logged in as Admin but as Guest it does.

I tried a fresh install of C5 and it works with Atomik but it is NOT working with Elemental.

Any ideas what I am missing? Shouldn’t the stock blocks be self-contained?
Thanks in advance for any insights.
C

I reported this issue in April - v9 Conversations Javascript Error · Issue #11369 · concretecms/concretecms · GitHub

In order to use this block I added a new file application/blocks/core_conversation/controller.php with this

<?php

namespace Application\Block\CoreConversation;

/**
 * The controller for the conversation block. This block is used to display conversations in a page.
 */
class Controller extends \Concrete\Block\CoreConversation\Controller
{
    public function registerViewAssets($outputContent = '') {
        $this->requireAsset('javascript', 'bootstrap');
    }
}

One of the lesser publicised quirks of v9 is that scripts and other assets are now loaded as ‘Features’. Each feature pulls in a bunch of related scripts and css (like pulling in an asset set in v8).

Blocks do this by declaring the controller with an interface and a method that returns a list of features to load. Overall quite neat, except the class declaration makes it impossible to code a block controller backward compatible with v8.

class Controller extends BlockController implements 
    FileTrackableInterface, 
    UsesFeatureInterface
{
public function getRequiredFeatures(): array
    {
        return [
            Features::IMAGERY,
        ];
    }
...
}

There is also an interface for themes to provide features overriding the equivalent core feature.

The asset system remains in operation. However…

  • Some v8 assets still exist and load.
  • Some v8 assets don’t exist and attempts to load them throw an error.
  • Some v8 assets don’t exist and attempts to load them are logged while the core continues.
  • Some v8 assets don’t exist and attempts to load them are completely ignored while the core continues.
  • Many addons and themes use the asset system for dual version compatibility and to register and require their own assets.

I have come across bugs where block type B worked when block type A was also on the page, but suddenly stopped working when A was not on the page. B was loading all its assets, but some of them no longer existed and were not reported.

Hence altogether a bit of an ambiguous mess for anyone updating from v8 and its not surprising that lesser used core blocks exhibit similar bugs.

My conclusion - Features are a great way of doing what they do, if only they had been implemented with a better appreciation of backward compatibility, consistency of failure modes, and perhaps making the error messages for missing assets mention ‘use feature ABC to fix this’.

The documentation is actually OK once you find it, but could be better. Searching on ‘Feature’ can create a lot of white noise because the word common.

1 Like

Thanks John, Hutman. Working perfectly now :slight_smile:

Apologies for digging up this post, a client of ours has just encountered the same issue, we found that the icons were also missing, so we modified @hutman very helpful solution to the following:

<?php

namespace Application\Block\CoreConversation;

/**
 * The controller for the conversation block. This block is used to display conversations in a page.
 */
class Controller extends \Concrete\Block\CoreConversation\Controller
{
    public function registerViewAssets($outputContent = '') {
        $this->requireAsset('javascript', 'bootstrap');
        $this->requireAsset('css', 'font-awesome');
    }
}

We now have all the icons, and a working conversation block.

1 Like