Block Question

Permalink
So I went to the auto-nav primer "how-to" doc, and I understand how to hard-code the autonav block into a template, cool.

But I tried this same thing with the TweetCrete block and it doesn't work. I tried:

$bt = BlockType::getByHandle('jereme_tweetcrete');
$bt->controller->showFollowLink = 'true';
$bt->render();

But it tells me I need a parameter in the render function. I tried to give it 'view' as the param, but no luck. Tried to instead say $bt->view(); but no luck either.

Can anyone help me? Surely it's fairly common to put a block that will be hard-coded into the template across the site?

Once I get it to render, will it be editable the same way normal blocks will--or how do I set it up to where there's settings in the block and I can call that instance of the block?

Sorry, I know this is a lot in one question, but I know some of you gurus out there have done this kind of thing.

clmedia
View Replies:
Mnkras replied on at Permalink Reply
Mnkras
$bt->render(view);
clmedia replied on at Permalink Reply
clmedia
Fatal error: Call to undefined method stdClass::render() in MYFILE on line 146
Mnkras replied on at Permalink Reply
Mnkras
stdClass?
clmedia replied on at Permalink Reply
clmedia
I know, right? I have no idea how to interpret it.
Remo replied on at Permalink Reply
Remo
sure the block handle is correct? It didn't return a proper block class instance..
clmedia replied on at Permalink Reply
clmedia
Yes--I checked the controller.php and view.php to be sure.

However--I got this working a different way with another script of my own.

But it'd be helpful to have an answer on how to do this in general. Is the typical way to do it $bt->render(view); of any block to get it to show the standard view.php? Or do you have to do more like is in the autonav "how-to" and say $bt->render('templates/autonav'); ?
jordanlev replied on at Permalink Reply
jordanlev
Not sure if this caused your problem, but note that you need quotes around 'view' in Mnkras's sample, so:
$bt->render('view');
TheRealSean replied on at Permalink Reply
TheRealSean
I just bumped into this problem and get the same error

"Fatal error: Call to undefined method stdClass::render()"

I am using the quotes around the view,
$block->render('view');


But still get the same error? never had it before but never really tried to call custom blocks into a template either?
TheRealSean replied on at Permalink Reply
TheRealSean
Ok bit egg on my face for me I was looking in the DB and noticed that the block I was trying to render was not in the BlockTypes table a quick look shows yes I had uploaded it but not installed the block so for me a Quick install and everything renders.

Having a quick look through the block_controller render function would this not also be beneficial to include a default view within the function? similar to the display function called from the models block

function render($view='view') { ..}