Closed (works as designed)
Project:
Drupal core
Version:
7.0
Component:
block.module
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
19 Jan 2011 at 02:03 UTC
Updated:
14 Jun 2018 at 12:38 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
wrburgess commentedThis appears to be the solution, but it seems a bit clunky and I have no idea about impact on performance:
Comment #2
kenianbei commentedhook_page_alter() or hook_page_build()
http://api.drupal.org/api/drupal/modules--system--system.api.php/functio...
http://api.drupal.org/api/drupal/modules--system--system.api.php/functio...
Comment #3
tinny commentedwhat wrburgess wrote works for me.
i added it to a node body field with php filter on.
'views' is the name of the module which created the block
'block_name' is the name of the block which can be found by going to the blocks admin page and hovering over the configure link.
i used it on the calendar module which uses a view to create the block:
Comment #4
morbus iffComment #6
pfrenssenThis also works and does not call any private functions:
Comment #7
yskel commentedThe snippet from wrburgess works for me, but I had to use the syntax:
Comment #8
kairrow commentedThis syntax worked for me as well. Thank you
Comment #9
Anandyrh commentedI use below code to embed view in to a node, it works perfectly
Now how do I pass 'CONTEXTUAL FILTERS' to this view?
Comment #10
pfrenssenAnandyrh, if you want to embed a view, then you can better use views_embed_view().
If you only need to render the content of a block (excluding the block title and containers), this simple code is sufficient:
Comment #11
Anandyrh commentedThanks a lot pfrenssen, I'll try it out.
Comment #12
b.ravanbakhshSee here for complete answer:
http://mydrupalblog.lhmdesign.com/embed-drupal-views-using-php
Comment #13
pfrenssen@b.ravanbaksh: don't follow the advice in the blog post you mentioned in #12: it bypasses the access control which is provided by views_embed_view(). This is bad practice and a security risk, potentially exposing sensitive data to unauthorized users.
Comment #14
arnoldbird commentedThis code does not work for custom block module blocks. For example, a block whose delta is 1. This does not work:
Comment #15
jmatuska commentedThe revised syntax from #7 works for me also, adding the " [view_name]- " in front of [block_name]. Puts the block into my node very nicely.
However, now i have a real test for you all. I'm trying to add my block INSIDE a wz_tooltip that is launched from an image map. I've made my tooltip sticky so it doesn't close, and I can add php inside the tooltip successfully, but as soon as I try to put this block code inside the tooltip code, it just ignores it and ends up putting the block further down the page AFTER the image map.
Any ideas?
Thanks for any help!
:) jean
i tried to put my code here for the image map and js tooltip, but i couldn't get it to work....
Comment #16
pipep commented#9 did the trick for me printing a block from page.php.tpl in D7
Thank you very much.
Comment #17
amitnaik commented#9 working perfect!!! just replace the delta of your block and its done! thanks @Anandyrh
Comment #18
FAAREIA commentedJust for the record. #9 is semi-correct but Drupal logs a warning message, since drupal_render need to be "alone".
Comment #19
ErikU commentedAwesome, thanks FAAREIA! #18 is the one to use as it doesn't cause Drupal to throw a warning message at all!!
Comment #20
charles belovPlease clarify #18. If cursoring over the configure link reveals that the module is "nodeblock" and the ID is 105487, that is, we are working with a block that can also be reached via /node/105487, so I tried the following code:
then
neither of which produces any HTML code.
(Yes, I know I wouldn't normally code a constant. I'm just trying to wrap my mind around what the difference is between a block name and a delta. And if I'm not using the literal "delta", then how do I determine the delta?)
Comment #21
charles belovOpening for follow-up comment.
Comment #22
charles belovFound the correct code at http://www.ultechspot.com/drupal/insert-block-node-or-template-drupal-7.
So my code would be:
$legendblock = module_invoke('nodeblock','block_view','105487');
print render($legendblock['content']);
where 'block_view' is a constant and the other two values are variables.
Comment #23
charles belovComment #24
sobi3ch commented#6 extended version with title/subject
Comment #25
rahul_sankrit commentedHere is sample code to render the views pro-grammatically in Drupal 7 in just one line:
Where:
VIEWS_MACHINE_NAME: The machine name of the view we wanted to render.
DISPLAY_ID: The display id which, we want to render of that view.
$view_arg: Argument value our view accepts. e.g. I've a view which display taxonomy on the basis of parent taxonomy, so this will be $term->tid.
More Details is here : https://api.drupal.org/api/views/views.module/function/views_embed_view/7.x-3.x
Comment #26
jansohan commentedThe below code not showing anything for the custom block render in the template file.
print render(module_invoke('block', 'block_view', '1'));