Concrete5.8.03 The Layout Presets

Permalink
Hi all

I am trying out the new version 8.3 and trying to get layout presets to work with my own grid system. I have lifted the following code from a 5.7 site which works perfectly but on 5.8 they don't appear as presets when adding a layout:

<?php
namespace Application\Theme\MyTheme;
use Concrete\Core\Area\Layout\Preset\Provider\ThemeProviderInterface;
class PageTheme extends \Concrete\Core\Page\Theme\Theme implements ThemeProviderInterface
{
    public function registerAssets()
    {
        $this->requireAsset('javascript', 'jquery');
    }
    public function getThemeName()
    {
        return t('MyTheme');
    }
    public function getThemeDescription()
    {


I have also tried adding the following with no joy but I did not have that in my working 5.7 site:

protected $pThemeGridFrameworkHandle = false;


I have tried debugging with both xdebug and actually just throwing exit() within the getThemeAreaLayoutPresets() to try and determine if it is actually running and it never seems to be hit. I don't know if this is a bug with v8. Has anyone else run into this problem at all?

Many thanks in advance
All the best
David

bvcreative
 
MrKDilkington replied on at Permalink Reply
MrKDilkington
Hi bvcreative,

I copy and pasted your page_theme.php code into the page_theme.php (the namespace was changed) of a theme I had installed and active in v8.0.3.

It threw an error:
Exception
No grid framework found. Grid area methods require a valid grid framework defined in a PageTheme class.

I then added a $pThemeGridFrameworkHandle value for a valid grid framework and was then able to continue without errors.
protected $pThemeGridFrameworkHandle = 'bootstrap3';

I believe you may need to declare a valid $pThemeGridFrameworkHandle to use the custom layout presets.
bvcreative replied on at Permalink Reply
bvcreative
Hi MrKDilkington

Many thanks for getting back to me, I did try that before hand as I found it in some documentation somewhere with 3 available values; boostrap3, false and I can't remember the last one if I am honest, and I can't find the documentation now unfortunately, when putting them in though, I still don't see the layouts.

Interestingly, I don't get an exception either which seems very strange. I have caching disabled, and I have tried clearing the cache anyway but still no change.

Very strange!!

All the best
David
MrKDilkington replied on at Permalink Reply
MrKDilkington
@bvcreative

If you ZIP your theme and attach it as a reply, I can take a look at it.
bvcreative replied on at Permalink Reply
bvcreative
Hi MrKDilkington

Thank you very much for your generous offer. Sorry for the delay, we have been stacked and I needed to strip some stuff out of it before I could send it.

Attached is a very stripped back version of it but it still includes all the core back end code which should be required.

Any advice you could give would be greatly appreciated.

Many thanks
David
MrKDilkington replied on at Permalink Reply
MrKDilkington
@bvcreative

When the theme folder name is snake_cased to match the CamelCased namespace name in page_theme.php, the theme installs and the custom layouts work.

I tested this on a 8.0.3 install with sample content. The working version of the theme is attached to this reply.
bvcreative replied on at Permalink Reply
bvcreative
Hi MrKDilkington

Aaaaah school boy error, I can't believe I missed that!! Thank you very much for your help, much appreciated.

For anyone else that comes across this thread, my issue was that my theme was named like:

my-theme


It should of been:

my_theme


If you don't mind me asking, would you mind removing the attachment? I thought I had removed all of the client sensitive data from it but I missed something so I would rather it not be available for download.

Many thanks
David
twoten replied on at Permalink Reply
I'm in a similar position. I copied the Elemental theme into application/themes/myTheme and enabled it. When I load a page, content that was in multiple columns is now in one column and I get an error message about no grid framework installed. In my page_theme.php it clearly states that
protected $pThemeGridFrameworkHandle = 'bootstrap3';

Also the H1, H2, and H3 definitions are different. I'll try searching for a log file to see if I can learn any more.
Gondwana replied on at Permalink Reply
Gondwana
I think you also need to change some namespaces or something:
https://documentation.concrete5.org/tutorials/how-to-copy-the-elemen...

It might be best to change the name of the copied theme too, lest there be confusion.

You could install Cloneamental, which has already done this for you.
twoten replied on at Permalink Reply
Hey that worked. My problem was that I named my theme directory with a capital letter in it. Next time I'll use cloneamental. Now I'm off to the races! Thank you very much!