Give the gift of Drupal. All merchandise is 50% off through 2016.
Last updated November 10, 2009. Created on November 10, 2009.Edited by LeeHunter. Log in to edit this page.
Advice on using blocks.
Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.
How to make all authenticated users see the same blocks across all user-selectable themes? It seems this would the the logical default, but is not, and there is no how to on making that so. Arg!
It is only possible to configure block visibility per theme as not all themes have the same regions. This is really the logical default as the code to detect if a theme has a region or not would add extra bloat to Drupal for a use case that doesn't often exist. It is easier all round (if not as convenient for some) to just let the user add the required blocks for each theme. Perhaps a contributed module could do what you describe but I don't know of any existing.
[Never mind, after looking at documentation guide, I wrote and submitted an article myself. Hey, I'm not a newbie anymore! :) ]
I'm a newbie and starting with D7, but an experienced PHP coder. It took me about 4 hours to successfully add PHP code to the body of a Custom Block. The problem was that the D7 install comes with the PHP Filter module disabled. So on the Block Configuration page, the Text Format drop down does not include the "PHP Code" option. Not knowing that there was even such a thing as the PHP Filter module, leaving "Filtered HTML" selected seemed the appropriate approach. I won't go in to all the frustrating and fruitless things I tried. But it would be helpful to put in the documentation, on Blocks, the fact that there is a PHP Filter Module, that it must be enabled, and you must grant permission to the admin (or whomever), before "PHP Code" will appear in the Text Format drop down, allowing you to write PHP code in the body of the Block.
Thanks for listening.
Well done for submitting the documentation where you saw the need, and a hearty welcome to the Drupal community! :-)
For anybody wondering why this module is disabled by default, allowing PHP input can introduce security problems when malicious users write malicious scripts and the potential to break the site with badly coded PHP, so it is a good idea not to enable it unless you really need it, and then make sure only responsible people (as few as absolutely necessary) have permission to use it.
Thanks for posting this!! I also have been trying to figure out what the deal with this is and I'm so grateful to have found your post - Agree that it should be apart of the documentation.
I am new to drupal and have just learnt the hook_block() function. I have created a custom module using hook_block() and have activated the module. However I do not find any option in drupal-7.4 to place the module as a block. The block administrator page has no option on how to add custom modules. Can anyone suggest?
You can see an example of programatically adding a block in the examples module: http://cgit.drupalcode.org/examples/tree/block_example/block_example.module
It's actually hook_block_info(), and that's where I would start. Fill out that function, enable your module, clear the cache, and then check. Once you see the block, then fill out hook_block_view() and any other hooks you might need.
I have a created a custom module that contains a simple zip code search form using the forms api.
It contains a textfield and a submit button.
In order to create a block that uses this module - what needs to happen?
I have created a new content type - but do not see how I would associate the new module, or a path to the new module to this content type (/audit_search_form/form). Am I close?
Drupal 7x BTW!!!
Great tutorial...works for me.
Does anyone know how to get the search functionality to search for terms within a block? I can search content fine but can't find anything with in a block.
I would look at this stackexchange and report your finding back there: http://drupal.stackexchange.com/questions/71616/drupal-7-search-through-block-content
Log in to edit this page
Drupal is a registered trademark of Dries Buytaert.