Custom Grid Framework breaks theme
Permalink 2 users found helpful
Hi There,
I followed this tutorial https://documentation.concrete5.org/developers/designing-for-concret... on how to create a custom grid framework. That worked perfectly on two sites. On the current project, I took exactly the same code, but as soon as I enter the edit mode, I get the following error:
"Class 'Concrete\Package\ThemeGre\Src\SpartanGridFramework' not found"
My Custom Grid is located in the src folder within my package (/packages/theme_gre/src/SpartanGridFramework.php):
I am initialising the grid like this in my package controller:
It is then getting activated in my page_theme file like this:
As already said, the same code worked on previous sites. All sites run on concrete 8.4.3. I found another forum post where someone seemed to have the same problem:https://www.concrete5.org/community/forums/customizing_c5/error-with...
I also tried to put my custom grid class to another location as it is done here:
https://github.com/mainio/c5_theme_bootstrap4_starter... but I get the same error, just with another path..
Besides that, I haven't found much useful information. It seems, that autoloading the class somehow doesn't work.. any idea?
I followed this tutorial https://documentation.concrete5.org/developers/designing-for-concret... on how to create a custom grid framework. That worked perfectly on two sites. On the current project, I took exactly the same code, but as soon as I enter the edit mode, I get the following error:
"Class 'Concrete\Package\ThemeGre\Src\SpartanGridFramework' not found"
My Custom Grid is located in the src folder within my package (/packages/theme_gre/src/SpartanGridFramework.php):
I am initialising the grid like this in my package controller:
use Concrete\Package\ThemeGre\Src\SpartanGridFramework; class Controller extends Package { public function on_start() { // enable the custom grid framework $manager = Core::make('manager/grid_framework'); $manager->extend('spartan', function ($app) { return new SpartanGridFramework(); }); } }
It is then getting activated in my page_theme file like this:
class PageTheme extends Theme implements ThemeProviderInterface { protected $pThemeGridFrameworkHandle = 'spartan'; }
As already said, the same code worked on previous sites. All sites run on concrete 8.4.3. I found another forum post where someone seemed to have the same problem:https://www.concrete5.org/community/forums/customizing_c5/error-with...
I also tried to put my custom grid class to another location as it is done here:
https://github.com/mainio/c5_theme_bootstrap4_starter... but I get the same error, just with another path..
Besides that, I haven't found much useful information. It seems, that autoloading the class somehow doesn't work.. any idea?
Do you have some lines like this in your package controller?
no I did not have such an entry..I tried your snippet but that did not work.. as already mentioned in my post, In my other pages I did not need any special autoloading registry entries and it works.. :-/
Some things changed between concrete5 5.7 and the v8 branch in the way paths are used. Sometimes changing the app required version in your package controller from an 8 version number to a 5.7 version number fixes the issue as C5 will then use the legacy structure. That works even if you are on a v8 version of C5, you just tell it to use legacy structure by indicating that your package is compatible with legacy 5.7 version.
Not guaranteed but it often works
Not guaranteed but it often works
Thanks for that tip, that would be the last option I guess.. ;-). It still confuses me though, that it is working with the exact same code on two other C5 Sites running the exact same version..
Jan, I'm working on bootstrap 4 and have everything working. I can send you what I have so you can see what I've done if you want. PM me and I'll send it to you.
Just downloaded your package. Put the bootstrap framework directly into the src folder.
Do you mean I should move the file SpartanGridFramework.php to the folder /application/src? Because it is already located in /packages/theme_gre/src
ok, I finally figured it out..
My required app version was set to 8.0.0 (that was also the only difference to my previous sites where the setup was working, which I changed without thinking about it..). Thanks @mnakalay for the tip with the legacy mode and thanks @tallacman for sending your example of your theme. (fyi, if I change $appVersionRequired to 8.0.0 in your theme, I get the same error with your theme..)
I therefore switched back to $appVersionRequired < 8 which makes it working for now, but it would still be interesting what actually the correct way to go would be to make it work with the new path system..especially since the legacy mode will probably not work forever..
I made a comment here:https://documentation.concrete5.org/developers/designing-for-concret...
Any input's how to actually do that correctly would be appreciated.
My required app version was set to 8.0.0 (that was also the only difference to my previous sites where the setup was working, which I changed without thinking about it..). Thanks @mnakalay for the tip with the legacy mode and thanks @tallacman for sending your example of your theme. (fyi, if I change $appVersionRequired to 8.0.0 in your theme, I get the same error with your theme..)
I therefore switched back to $appVersionRequired < 8 which makes it working for now, but it would still be interesting what actually the correct way to go would be to make it work with the new path system..especially since the legacy mode will probably not work forever..
I made a comment here:https://documentation.concrete5.org/developers/designing-for-concret...
Any input's how to actually do that correctly would be appreciated.
Here is a working example of a custom grid framework for v8 https://github.com/hutman/concrete5-bulma-theme/tree/master/bulma...
thanks for your example. Apparently, after all, it was the entry in pkgAutoloaderRegistries, which you already asked above..I must have made something wrong the first time i tried that..
Besides that, I also had some of the grid markup methods giving back wrong things, now those have been fixed, everything works.
I also updated the tutorial here:https://documentation.concrete5.org/developers/designing-for-concret... (changes currently under review).
Thanks for your help guys.
protected $pkgAutoloaderRegistries = array( 'src' => '\Concrete\Package\ThemeGre\Src' );
Besides that, I also had some of the grid markup methods giving back wrong things, now those have been fixed, everything works.
I also updated the tutorial here:https://documentation.concrete5.org/developers/designing-for-concret... (changes currently under review).
Thanks for your help guys.
Hey Hutman I see your using Bulma as your grid framwork. I knew there was a reason I liked you guys.