getThemeAreaClasses() for areas with any name

Permalink
I need to have a choice of classes for areas available. In pagetheme.php I have:
public function getThemeAreaClasses()
    {
       $classes = array();
        for ($i=1; $i < 99; $i++) {
           $classes['Area '.$i] = array('small-blog-entry','medium-blog-entry','large-blog-entry');
        }
        return $classes;
    }

That works fine. But in order to have classes avalable for areas with any name I couldn't make it work.

For getThemeBlockClasses in pagetheme.php we have the wildcard character * for classes available to any block.

public function getThemeBlockClasses()
    {
   return [
               'core_area_layout' => [
                'section-fluid',
           ],
            '*' => [
      'is-expanded',
      'grid-item--width2',
                'zoom-box',
                'hidden-print',
               ],
        ];
    }


I tried the to get preset classes with the wildcard asteriks for areas, but it won't work.

What am I missing?

blinkdesign
 
mnakalay replied on at Permalink Reply
mnakalay
You're not missing anything the wildcard * was not implemented for areas.

I think the idea is, since getThemeAreaClasses() is implemented in page_theme.php so from within the theme, you most likely have a limited number of differently names areas that you have control over so you probably don't need a wildcard.

It would indeed be useful sometimes but that's the way it is, you have to find another way.

One thing you can try is using the function getHandleList() which gives you a list of all distinct area handles available. That function is in concrete/src/Area/Area.php
That will also include global areas and sub areas.
It's a static function so you can do
$areaList = \Concrete\Core\Area\Area::getHandleList();
blinkdesign replied on at Permalink Reply
blinkdesign
Thanks for replying.
I'd be using it for an Isotope Image-Blog. Using getHandleList is too complicated for me. My client would have been delighted to have an easier workflow. I guess I have to hardcode the areas in the page template.
mnakalay replied on at Permalink Best Answer Reply
mnakalay
Your code just requires some tiny modifications to work. Try this:
public function getThemeAreaClasses()
{
    $areas = \Concrete\Core\Area\Area::getHandleList();
    $classes = array();
    foreach ($areas as $area) {
        $classes[$area] = array('small-blog-entry','medium-blog-entry','large-blog-entry');
    }
    return $classes;
}
blinkdesign replied on at Permalink Reply
blinkdesign
d'y donc!
works like a charm.
thanks a lot.