Using blocks of repeated content in Drupal

Hi I am used to creating 'flat/dynamic' websites using Dreamweaver and one of its' features is a so-called 'library' element. This is used when say a block of content is repeated on a separate number of pages and you don't want to just copy create this separately for each page. All you do is create this block once, save it as a library item and then just drag/drop it into each page where it is required. It also means that when you update this block it automatically updates all other pages where it is stored. Is there a similar feature/technique's I can use in Drupal? Thanks guys

Comments

dokumori's picture

Question: 'Is there a

Question: 'Is there a similar feature/technique's I can use in Drupal?'
Answer: Yes. I don't know about Dreamweaver's library you mentioned, but I suppose it's an element you paste in a static HTML page? Then it gets automatically updated after change is made, like how paths are updated?

In Drupal, all pages are rendered dynamically. When you create a block, you specify in which pages you want this block to appear in 'page specific visibility settings'. The block will then get rendered along with the page you specified.

Drupal blocks and "Role specific visibility settings"

OK that's great and thanks for your help. However, can I control where the block of text appears on the page (ie not just at the bottom of the page but say 1/2 up or even at the top of a page? Thanks
Robert Castelo's picture

Easy

You have control of the order your blocks are displayed in, through the Blocks administration page. For more control use CSS to make the block look exactly how you want.

Try this...

It depends on how "custom"

It depends on how "custom" your implementation is. I often have the situation where I want block content to appear on node pages of specific types and not others. In which case you can use the PHP option in the "Role specific visibility settings" to check for the node type and return a true/false. Or you can call a PHP routine from there which evaluates whether to display the block. When it comes to deciding where to put the block in relation to other blocks that's fixed. However you can build your own module that uses hook_block to define a set of "duplicate blocks", then use module_invoke('modulename','block','view',blockdescriptor) to call the module that's generating the block to give you a copy of the content. Then you can place each of your "duplicate blocks" in a different place on each page they're supposed to appear. If it's your own block content just define multiple blocks that call the content creation function directly rather than using module_invoke (which takes longer). Steve Turnbull As an aside: when it comes to my own blocks I dislike using the page visibility settings because it means I have code related to the same thing in two different places. So I actually put the "visibility" code inside my code creation routine and bug out if this page doesn't require the block. If a block has no content it doesn't appear. Drupal 6 has far better module control of blocks.

.

ooops.

the PHP option in the "Role

the PHP option in the "Role specific visibility settings" workin well in this case ___ indiana mobile homes