BlockType::getByHandle

Permalink
Working with a static block in a theme.
Here is my code...
$bt = BlockType::getByHandle('auto_nav');
// some more settings
$bt->render();


But it's not working. It keeps loading and returns an "allowed memory exhausted" error after a while.

Seems that the "loadController" method in the BlockType class isn't working.
Having this issue in C5.8.3

Any suggestions?

DeWebmakers
View Replies: View Best Answer
hutman replied on at Permalink Reply
hutman
Check out this documentation and see if it can help you

https://documentation.concrete5.org/developers/working-with-blocks/w...

It also could be that your autonav is just too big to display without running out of memory and you need to up the allotted resources for your site.
DeWebmakers replied on at Permalink Reply
DeWebmakers
Tried this and still no joy....It's not working.
Just try only to load the block, no settings and no render... It will break immediately...
hutman replied on at Permalink Reply
hutman
Can you explain what "It will break immediately" means? Do you see an error? Does it throw the same out of memory error? Have you tried upping your timeout and allowed memory on the server?
JohntheFish replied on at Permalink Reply
JohntheFish
I suspect it is missing various settings.config, so causing a code error, such as method on non object.
DeWebmakers replied on at Permalink Reply
DeWebmakers
It keeps loading until the browser tells me that the page can't be loaded. It looks like an loop or something. There are no errors or something. Upping time and memory just takes longer for the browser to break, but it still breaks. I think this is a 8.3.2 bug. Could you guys check in a testing environment?
hutman replied on at Permalink Reply
hutman
I placed this into my default.php in a test environment and it displays as expected

$bt = BlockType::getByHandle('autonav');
$bt->controller->orderBy = 'display_asc';
$bt->controller->displayPages = 'top';
$bt->controller->displaySubPages = 'relevant_breadcrumb';
$bt->controller->displaySubPageLevels = 'all';
$bt->render();
DeWebmakers replied on at Permalink Reply
DeWebmakers
In 8.3.2?
hutman replied on at Permalink Reply
hutman
Yes.
weyboat replied on at Permalink Best Answer Reply
weyboat
Try using ('autonav') instead of ('auto_nav')
DeWebmakers replied on at Permalink Reply
DeWebmakers
Hi guys,

Sorry, but I made a mistake... I'm testing with an addon I'm trying to get online.
I've tried to add a block manually in the theme and it works! Just like you guys said. So that's that.

I tried to load a block in a controller of a dialog window in the Dashboard. There $app isn't available and the whole thing breaks...

So, fixed for now.

Thanks!