Field as Block is a lightweight module that allows you to display a field as a block. The same results can be achieved by using Panels, Display Suite or custom code but this module offers a lightweight alternative.
CCK Blocks offers similar functionality, however on the project page they recommend that you use Field as Block for new projects. It looks like CCK Blocks will be deprecated in favour of Field as Block. For more details read issue #1920636 (comment #4).
In this tutorial we’ll use the module to display a “Call to action” field as a block in the sidebar second region.
Before we begin just download and enable the Field as Block module.
If you use Drush, run the following command:
drush dl fieldblock drush en fieldblock
Create Call To Action Field
First we’ll need to create a long text field called “Call to action” on the Article content type.
1. Go to Structure -> “Content types” and click on “manage fields” in the Article row.
2. Create a “Call to action” field using the values defined in Table 1.1.
Table 1-1. Create long text field
|Label||Call to action|
|Field type||Long text|
|Widget||Text area (multiple rows)|
Display Field As Block
Now that we have our “Call to action” field the last bit of work we need to do is configure the field to be displayed as a block, and then display that block in a region.
1. Go to Structure -> “Content types” and click on “manage display” in the Article row.
2. In the Default view mode select the “Display as block” checkbox in the “Call to action” row and click on Save.
3. Go to Structure -> Blocks and assign the “Call to action field (from node: Article: default)” to “Sidebar second” region.
Now that everything has been setup, let’s go and test the field and make sure it displays as a block. First, go and create an article and add some text into the “Call to action” field.
Once you have saved the form, the text should appear in the “Call to action” block within the “Sidebar second” region.
If you move the “Call to action” formatter to the Hidden area on the “manage displays” page, the block will not appear, even though you have ticked the checkbox.
Make sure the formatter is always enabled and not hidden.
If you have any questions, please leave a comment.