5

I've created a content type called "News" with the following fields:

  • Body
  • Image (using Insert module to allow user to insert picture into the body)
  • Body Sidebar (a field collection, surrounded by a with the following fields)

Body Sidebar has two fields:

  • BS Title
  • BS Text

I want to be able to give the content creators an easy way to insert the sidebar into the body in a similar way they can with the image field. As far as I know the Insert module can't be used to do that.

Is there any way to allow users to insert the Body Sidebar div into the Body field? If not, is there a way to do this programmatically?

Apologies if this is elementary, I'm very new to Drupal.

1
  • I have programmatically solution,why you do not that in form_submit?
    – Yuseferi
    Commented May 27, 2014 at 11:22

5 Answers 5

1

You might be able to use the EVA: Entity Views Attachment module to attach the data to the node, but I'm not sure.

"Eva" is short for "Entity Views Attachment;" it provides a Views display plugin that allows the output of a View to be attached to the content of any Drupal entity. The body of a node or comment, the profile of a user account, or the listing page for a Taxonomy term are all examples of entity content.

1
  • I haven't used EVA, but the issue with using that is (I assume) the user actually needs to create a view for this method to work. I want them to be able to enter data into the Body Sidebar collection fields, and use that div in the body without having to create a view as well.
    – mgwisni
    Commented Aug 30, 2012 at 21:02
1

You can do it with Block Inject module easily, you can watch the video Demo here.

You can create any number of regions to inject as well as select as many node types you would like these regions to be injected in. The blocks you assign to these regions will then appear in the middle of the body field of these node types if the number of paragraphs is bigger than 2.

with this module you can achieve your requirement easily by creating a view block with the required field and assign that block to the region it will render your block inside the body field.

0
1
+50

There are already some good suggestions here. Additionally, I would like to recommend taking a look at the module field injector field formatter widget maintained by Dave Reid. It enables you, for example, to insert any view list via the views field module and can be set to where exactly the injection should happen. After the first or the second or before the last paragraph. This is the most flexible way in my opinion and enables you to even reuse this in another view showing the content with the injected view in the body again.

0

I recommend using views if you are not using that module already. Views gives you the ability to render content form 1 or more nodes in a block.

Add the sidebar title and sidebar summary fields to your content type, then create a block that displays these fields using views.

You should only have to create one view, which will render the information if the information is provided by your users.

You can set this view block to appear in the content section on in a sidebar by rearranging you blocks on the block settings page.

0

just edit the contenttypes node.tpl.php file (like node--news.tpl.php),

if you want that field in the sidebar, use views, create a views-block displaying the two fields with the actual node as contextual filter and put that block in the desired region.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.