2

I am new to Drupal and I am learning pretty fast. However I am stuck on an issue.

I need to make a custom Block for my content (node) images.

There is a system-made content block which pulls from the node form of content type "Basic Page". I've added a "Image upload field" to that so I can upload images within my content.

I am able to render the field on the page after adding the content block to the content region, However, I need to show just that image of that node in some other region.

How can I do this?

3

Use Views module for this. In D8 the views module is part of the core, in D7 you need to install it

1) Go to Structure > view

2) Add a view which shows content of type Basic page. Check on create a block.

3) Select the fields to be shown as image (as you want)

4) Under Advanced (on the right side of the view, click on it to expand)

CONTEXTUAL FILTERS click add, and select ID (D8) or Nid (D7) and then choose "Provide Default Value" and Under type select "Content ID From URL". click on Apply and save the view.

enter image description here

5) In structure >blocks, place the block in the region you want to on the content type you wish (In your case Basic Page).

6) Go to your basic page content and you will be able to see the image which belongs to that node only in the view block you have placed.

  • sorry I have gotten lost in you instructions on step 4. I am using D8 – samjco Dec 19 '17 at 7:12
  • 2
    on step 4 under "Provide default value" you can select "Content ID from URL", then you don't need to pick the path component. – 4k4 Dec 19 '17 at 8:28
  • Sorry, I don't see what you are talking about anywhere. I selected a new view chose the content type to basic page... then its has 2 checkboxes "Create a Page" and/or " Create a Block". After I chose a block, the I go and and change fields to "image" but I do not see any "Provide default value".. – samjco Dec 19 '17 at 9:00
  • 1
    @samjco : At the right hand side of the view, you will see an option of advanced filters. Expand it, then click on add in front of contextual filters and then select ID, then choose provide default value and select "CONTENT ID from URL" as stated in above comment – Anupriya_vij Dec 19 '17 at 9:12
  • 1
    @NoSssweat : yup, I have already mentioned it in above comment of mine. Thanks for the edit :) – Anupriya_vij Dec 19 '17 at 10:59
0

You can use Field as Block module for that scenario.

I often use it to place the node content in one region, and node image in another -as a dynamic block.

  • Can't find instructions on how to use this module. – samjco Dec 19 '17 at 7:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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