$this->action not working in block manually inserted into template
Permalink
I have hard coded the jb_register addon into my template using code (not using the editor interface) and in it's view.php it calls $this->action('submit_form') but it's empty. I traced it in the debugger to the blockView's block is null.
It also seems that the header items in on_page_view aren't being inserted so I had to manually add them to the template.
Otherwise the addon is working fine embedded through code. Am I missing something with how to embed a block directly in the template through code or is this a bug? Here is my code to embed the addon:
It also seems that the header items in on_page_view aren't being inserted so I had to manually add them to the template.
Otherwise the addon is working fine embedded through code. Am I missing something with how to embed a block directly in the template through code or is this a bug? Here is my code to embed the addon:
$bt = BlockType::getByHandle('jb_register'); $bt->controller->signupMethod='go'; $bt->controller->style='tabbed'; $bt->controller->addToUserGroup=4; $bt->controller->hideWhenLoggedIn=1; $bt->controller->showWhenLoggedIn=0; $bt->controller->showWhenNotLoggedIn=1; $bt->controller->showLoginForm=1; $bt->controller->hideLoginFormRegistered=1; $bt->controller->showLogoutFormRegistered=1; $bt->controller->showPasswordRecover=1; $bt->controller->hidePasswordFormRegistered=1; $bt->controller->enableCaptcha=0; $bt->controller->redirectAfter=0; $bt->controller->redirectAfterLogin=0;
Viewing 15 lines of 30 lines. View entire code block.
![zanedev](/files/avatars/54530.jpg)
anybody out there have any experience with hard coding blocks into templates?
Any js and css assets for hard coded blocks don't get automatically loaded because there is not really a block, just a view of a block.
Thanks for the response john, so that sucks is there any way to embed a real block instead of a view of a block through code? I take it that's why $this->action isn't working either..
You could try putting the block in a stack and embedding the stack. However, I suspect it may just end up adding another level of indirection to the same base problem.
It may be easier to use simply edit a suitable global area into your theme and add the block to a global area.
It may be easier to use simply edit a suitable global area into your theme and add the block to a global area.
$this->action requires a block ID, and when you hardcode it, as John said, its just a view, so it has no block ID
Thanks I'm aware of that now and would like to know if there is any way to hardcode a block with full functionality exactly the same as if I embedded it through the editing interface. I would say that is a nice feature request if not available...
For now I used the editor to embed it as a global block at the bottom of the page and hide it when not in edit mode. Luckily this is a block that I can hide since it is shown in an overlay as needed. The drawback is the block is visible and editable at the bottom of every page which is confusing to an editor to see that at the bottom everywhere.
For now I used the editor to embed it as a global block at the bottom of the page and hide it when not in edit mode. Luckily this is a block that I can hide since it is shown in an overlay as needed. The drawback is the block is visible and editable at the bottom of every page which is confusing to an editor to see that at the bottom everywhere.
I found this thread that dives deeper into these issues and workarounds..
http://www.concrete5.org/community/forums/customizing_c5/developer-...
http://www.concrete5.org/community/forums/customizing_c5/developer-...