Custom Classes for Blocks

Permalink
I have created custom classes, but they are not showing up. When I click on a block, and choose Design & Custom Template, there is nothing in the Custom Class box to choose from.

This is my code ... what have I done wrong? These classes ARE in my stylesheet, FYI.

public function getThemeBlockClasses()
{
return array(
'image' => array(
'img-border-padding'
),

'image' => array (
'img-circle'
),

'*' => array(
'padded-yellow-bg'
)
);
}


Thank you.

ssailer
 
rge replied on at Permalink Reply
Hello,

The getThemeBlockClasses method should be placed in the page_theme.php file which is located in the theme folder.

Use the elemental theme as reference: concrete\themes\elemental\page_theme.php. It is also important that the theme is installed and activated.

Example from the elemental theme
public function getThemeBlockClasses()
{
    return [
        'feature' => ['feature-home-page'],
        'page_list' => [
            'recent-blog-entry',
            'blog-entry-list',
            'page-list-with-buttons',
            'block-sidebar-wrapped',
        ],
        'next_previous' => ['block-sidebar-wrapped'],
        'share_this_page' => ['block-sidebar-wrapped'],
        'content' => [
            'block-sidebar-wrapped',
            'block-sidebar-padded',
ssailer replied on at Permalink Reply
ssailer
Thank you for getting back to me. I do have a page_theme.php page which is in my theme directory, and the theme is installed and activated. I will try taking a peek at the Elemental theme code and see if it can point me in the right direction. I wish there was better documentation for accomplishing this! :/

Thanks for your help.
rge replied on at Permalink Reply
There is some documentation available related to this subject.
https://documentation.concrete5.org/developers/designing-for-concret...

But still, it is a good thing to look in the core to see how things are done.

Goodluck.
ssailer replied on at Permalink Reply
ssailer
Thank you. One question ... does the stylesheet have to be in a folder called css, or can it be named anything?
rge replied on at Permalink Reply
If you use Concrete to compile the less the answer is yes.
<?php echo $html->css($view->getStylesheet('main.less')) ?>

The getStylesheet method calls the getStylesheetObject. In here the constant DIRNAME_CSS is used wich has the value css.

However, it is not mandatory. You can provide a CSS file yourself.
https://documentation.concrete5.org/developers/designing-for-concret...

You can parse the less/sass yourself using task helpers like Grunt or Gulp. If you have installed Concrete via composer (see the download page) you can also use Laravel mix to do this.
ssailer replied on at Permalink Reply
ssailer
Finally - it's working. I think the problem was that I didn't deactivate and remove the theme after making my changes. Thank you for all your help! :D