Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By rahil on
Hi
I want to call custom_search module block without using regions in page--mypagename.tpl.php
Comments
.~.
Could you provide some more details..like what actually you are trying to do.
How about.... <?php echo
How about....
echo menu_block_view('main_menu');
menu - the module.
main_menu - the block delta.
That's the way I roll.
BTW - If you like to display menus that are dynamic I recommend using menu_block module!
Drupal 7: This WORKS for me...
I found this
(here: http://api.drupal.org/api/drupal/includes--module.inc/function/module_in...)
This only works form me...
How do I load the block title
How do I load the block title in drupal 7?
I can get the content using:
and I've tried print render($block['title']); and print render($block['header']); but I can't work out what I should be calling in the array to get the title.
print $block->title;
print $block->title;
this's really helpful
Hi,
this is really helpful, you saved my time, thanks
Render block in custom page tpl.php drupal 7 without any error
With wrburgess's answer, you may get an error if your server is using a newer version of PHP.
Strict warning: Only variables should be passed by reference in include()...
This is what I did to not cause/get rid of the error.
Best regards,
Omprakash Mankar
Senior Drupal Developer
Thank you! This worked for me
Thank you! This worked for me.
:) views_embed_view works fine IMHO
https://drupal.stackexchange.com/questions/8369/how-do-i-programmaticall...
---
Kind regards,
Thank you,
Rakesh James
Have in mind that
Have in mind that
only works for blocks, or other elements such as pages, created within a view.
The code
works for any block that you may want to render.
It worked for me! Thanks.
It worked for me! Thanks.
How/where to use this code?
@jucedogi I have a .tpl.php file I created based on Theme dubug file name suggestions:
with that file now created, content I write in the file appears but it overrides the Block content, how do I use your code to render and apply classes to the block, rather than replacing it?
EDIT: I placed this into my .tpl.php file and it rendered the block :
The code examples given won't
The code examples given won't alter the output of the content that is being called upon.
Templates you use will display whatever you place on them as you noticed. I understand that you are using views to create a display. If you wish to replace the output then you need to find the corresponding template with the content you wish to alter.
On the advanced section of the view edit there is a theme information link in the lower area where you can get all the possible templates with their standard content. I believe what you are trying to alter would be in one of these template suggestions.
Depending on what you are trying to achieve you could also use a custom text field in which you would place the output of other fields within your custom markup.
Thanks @jucedogi do you have
Thanks @jucedogi do you have any code examples of how I could render a particular field rather than the whole block?
For example if 2 of 3 fields from a view or a block are find, but one needs-some fine-tuning with style, how I could separate the fields out and render them on the page?
There are methods that help
There are methods that help you achieve this such as field_view_field.
If you need to modify the output of a specific field then you could also use the template system and make a template for said field. Look in the core modules for the field theme base template to start it out.
Thank you jucedogi, Your code
Thank you jucedogi, You code has been of great help to me.