Adding Templates via Code
Permalink
Hey guys,
I'm having trouble adding templates to a block via code. It only seems to work if a block has previously been assigned a template through the drop-down menu method in the dashboard.
Here is the code I'm using:
Any help is appreciated, thanks!
I'm having trouble adding templates to a block via code. It only seems to work if a block has previously been assigned a template through the drop-down menu method in the dashboard.
Here is the code I'm using:
$bt_main = BlockType::getByHandle('autonav'); $bt_main->controller->displayPages = 'second_level'; $bt_main->controller->orderBy = 'display_asc'; $bt_main->controller->displaySubPages = 'relevant'; $bt_main->controller->displaySubPageLevels = 'all'; $bt_main->render('templates/side_nav_bar/view');
Any help is appreciated, thanks!
I don't think this is the problem. When you add a block by using some php code you usually have to include the javascripts manually.
Concrete5 checks all block instances before rendering the html header and includes all css and javascript files used by these blocks.
But if you add them using the code posted above Concrete5 can't include these files and a dropdown menu won't work...
Concrete5 checks all block instances before rendering the html header and includes all css and javascript files used by these blocks.
But if you add them using the code posted above Concrete5 can't include these files and a dropdown menu won't work...
Yeah thanks Remo, I actually figured this out a bit later, never got back here though to post the answer.
It was, like you said, the stylesheet wasn't getting included. I figured having it named the same as the template would have meant it was going to be picked up automatically.
Thanks again
It was, like you said, the stylesheet wasn't getting included. I figured having it named the same as the template would have meant it was going to be picked up automatically.
Thanks again
to:
I think you are adding the name of the view.php file there and you don't need to. it will automatically look for that file.