Drupal 7 Nodeblock module

By shane
Wed, 2014-05-07 06:15
Daily Dose of Drupal Episode #147

Share with Others

The Drupal 7 Nodeblock module is a simple but handy module that can be used to turn nodes into blocks on your Drupal 7 website. Essentially you pick a content type that you want to use to create new blocks, and when you create this type of content, it's now available on the block administration page. This can be really useful for you to set up client websites using this module, this way someone unfamiliar with Drupal does not have to learn how to use the standard Drupal Block administration and can instead just edit the content. It's often confusing to new Drupal users on where exactly they can find where to change specific pieces of content on their site, this module can help with that.

In this episode you will learn:

  • How to create a content type that uses Nodeblock
  • How to create an position Nodeblock
  • What some of the additional settings are for the Drupal Nodeblock module

Hello everyone and welcome to another Daily Dose of Drupal. As always I’m Shane and you can follow me on Twitter at smthomas3, also make sure if you haven’t already to follow Adam Learing on Twitter as well, the newest member of the Code Karate team.
Today we’re going to be going over the Node block Module and this is probably one of the simpler module you’d use but it does have some really useful purposes especially if you need to allow maintainers of the site or if you’re building a site for a client and you want that client to be able to able to change the content of blocks without actually giving them access to the Block Administration page.

So you can do that using the Node block Module. So I already have this module dropped in our development site here so we’re going to go ahead and turn it on, so I’ll go ahead and enable that and the way it works is pretty simple, you simply create a content type and there’s a setting to allow it to be a block and then as soon as you enable that, any content you create under that content type will be available for you to move in the blocks administration page.

So if I come back to Structure and I create a content type we will create a content type called Node Block. And the important setting here is this node block settings, you’re going to make sure you select Enabled here, you can also change the Default View Mode so if you’d like to select different view modes so the content shows up a little differently, you can do that using the View Mode here.

If you want to show or hide the links by default it’s hidden and in most cases you probably want to keep that the same and the same with Comment Display. You’ll probably want that hidden but you could have it shown as well. There are options to override on a per node basis which will allow you to change this when you’re creating the node.

For instance if you selected available as a block when you’re creating a node you’re going to be able to change if you actually want this node to be a block or not. Since I’m only going to be using this for blocks specifically I’m going to leave all those unchecked. So you can go ahead and click content type.

Now if I come back and add content and I’m going to add a Node Block Content, so I’ll add just a quick little node, I’m going to not put this on the front page and I will save it.
Now you can see this looks pretty much the same. If I come back to the Block’s administration page, here’s when I was testing them, I’m going to go ahead and get rid of that but if you look down here there’ll be a highlighted content which just takes the title of … or the node title and uses that as the block title and you can go ahead and change that to wherever you want in the Blocks Display and if we save that … so I put that in the highlighted area which just show up on the top of every page you can see now highlighted content.

Let’s go back to the homepage and you’ll see that my highlighted content just shows up. You can come in and edit the block and actually brings you to edit the actual node itself. So I’m going to do a couple of things, I’m going to go to the Content Types page and go into Edit our Node Block and let’s say for instance we didn’t want to display the author and date information. We can change that, click Save, if we come back to the homepage now you can see the author and date information is no longer displayed so it looks more … more closely it resembles the Block now.

There are a few other things you can do, if you come into the Content Types page and you go to Manage Display. If you had additional fields you could change how this is displayed or you could of course add a new display such as the RSS Feed or Search Index and that will just basically allow you to have finer control over the display of this. If you need a simple block though the default settings are fine and will work for you.
You can go ahead and move it to other locations just to see that it works, if I move it over into sidebar first it is of course going to show up over in the sidebar. This way your clients are able to use just the normal contents adding in content and editing features of Drupal without having to learn anything about blocks which can be confusing especially if you haven’t spent a lot of time with Drupal sites.

So it’s just one way to make your client’s life easier or make website management of Blocks easier for users who don’t want to really get into detail with how Drupal works. Let’s go ahead and give that a try and let me know what you think and make sure to follow me on Twitter and sign up for the Code Karate Newsletter over here on the left sidebar if you haven’t already, of the codekarate.com website. Until next time, I’ll see you later.