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.
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.
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?
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?
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?
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.
Comments
How to make all authenticated users see the same blocks across
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!
Phoenix.Consultants.Nepal (www.phoenixstudiosnepal.com)
It is only possible to configure block visibility per theme
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.
Writing PHP in body of a custom Block in Drupal 7
[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.
Restrict access to PHP input filter
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.
Boz, Thanks for posting
Boz,
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.
ruess
How to add module as box
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?
How to add module as box
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
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.
How to add a custom module to a block.
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!!!
Solved :
http://www.summasolutions.net/blogposts/how-create-basic-block-code-new-...
Great tutorial...works for me.
Search within block: Drupal 7
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.
Thanks
Sharon
I would look at this
I would look at this stackexchange and report your finding back there: http://drupal.stackexchange.com/questions/71616/drupal-7-search-through-block-content