0
votes

I might be asking for a lot , but any help would be awesome! All I want to do is every time a user (not admin) in Drupal creates content like a blog, predefined blocks in certain regions will allow user to add NEW content (ad's/banners). Is this possible?

I've seen the Node-Level Block, but I am not too sure on how to use it? Would this work? How?

Here's an example on what I am asking above. Say a user has permission to create a blog. They will add content to the blog, along with an option to add new content to predefined blocks, like the right side bar block named RightSideBarBlock. This content per block, will be only seen for that new node created from blog content type. If they do not add content to predefined blocks, the block will show nothing for that node.

Does this make sense?

1
Are you looking for suggestions on how to handle the creation of the related content for the block, or just on displaying the related content block? - Quint
How to create blocks that allow new content to be put inside them EACH time new content like a new Blog is created. Basically user(NOT ADMIN) can create new content in the blocks, but where the block are located on the PAGE, DO NOT CHANGE(unless Admin changes) and the content in the Block can only be edited when content like Blog is created/edited. Nodeblock might work, but I don't understand how to use it with what I want to do with it. - Benjamin Jones
Maybe Boxes work work? drupal.org/documentation/modules/boxes Opinion? - Benjamin Jones

1 Answers

1
votes

The display part of your request is fairly easy. You don't have to create a new block for each blog entry, you can use the views module to display the related ad for each entry.

Before starting, make sure you have the views module and the entity reference module installed.

First you need a new content type, call it Blog Ad. It will need a field called Owner that will be an entity reference field pointing to the parent blog entry.

Next, create a new view and make sure you choose to create a block variant and set the number of entries to display to 1. Set the filter criteria to Content Type = Blog Ad. Add a context filter to the view. Select Content: Owner from the list of options (this will let you filter the Blog Ad entries by the owning node id). Since block views can't take arguments directly you have to choose the option to provide a default value. From the option list select Content ID from URL. Save your view and go to the Blocks page.

You will now have a block in in your Blocks page called View: < Name of View >. Add that block to the appropriate region, and under settings, filter it to only appear when the content type is Blog.

Now you can create a Blog entry, save it, create a Blog Ad entry selecting the just created Blog entry in the Owner field, then view the Blog entry. You will see your Blog Ad in the block. Create a new Blog entry and when you view it you won't see anything in the Blog Ad block.

Allowing creation of the related Blog Ad from the Blog creation page can be accomplished using a module like Node Reference Create or Inline Entity Form. I have not used any of these modules personally so I can't vouch for their quality or ease of use, but they will do what you want.