2

How would I go about creating a block that displays the current page's author name, picture and short bio? I'm new to Drupal and don't know if this is done using a View block, custom block or by editing a block template. The block should only display if in a page or certain content type.

enter image description here

  • Can you clarify in your question regarding, How many blocks do you need? Do you want Two separate blocks (1) About the Author & (2) The Latest stuff. About the author is clear here. But what is latest stuff, Latest stuff of the entire site OR latest stuff by that particular author. Or do you want all things in one block only. – CodeNext Jul 16 '16 at 11:17
  • I deleted my answer because it did not answer the question I now realize you were asking. You need the author details of the viewed page in the block. – cilefen Jul 16 '16 at 15:14
  • This is a old post, but possibly something like drupal.org/project/block_user_info. – stefan Mar 22 at 16:41
4

This will be little bit lengthy process but can be done. This you can do by Views module which is in core in Drupal 8, BUT before that you have to do some other stuff with the user account. The entire process I am listing out in steps.

Since your question is not complete clear, I am providing the method for Author Info only, if you clarify I will add the second part.

Author Info Block

  1. Adding - Bio field & Social media profile field
  2. Creating Views.
  3. Add created block to appropriate place.
  4. Block visibility setting

1. Adding - Bio field & Social media profile field

Now, the user profile setting do not provide the Bio field by default hence we need to create that one.

1.1 Go to Configuration>Account Setting>Manage field

1.2 Add new field name: Bio, field type: Long text(formatted, long)>save

1.3 Add new field Social Links: Install and enable the Social Profile Field. What this module does, this module provide the field which provide the provision for adding the social media links, The link will automatically converts to ICONS, that is the good part.

Again go to Configuration>Account Setting>Manage field and add new field Social link and for this choose field type: Social profile field. Note: The picture field is by default, which provides by core.

The final screen shot will be looks as below, enter image description here

Now, Under the user profile- Bio and Links will be added as new field so you can add this by going under Edit of any user profile.

Now, we add set to go for Views,

2. Creating Views: Author info

2.1 Go to Structure>Views.

2.2 Add new view: Author Info. Select Users in views setting. Select Create a block in Block setting. Set Unformatted list of Filed under Block display settings. Select 1 under items per block. Click->Save and edit.

2.3 Views setting page:

2.3.1 Now add Relationship: Go under Advanced setting. under relationship click add and from the list select Content Author, give it a name Author node as shown in the following image of 2.3.4.

2.3.2 Now add contextual filter: Same as above step, click add to contextual filter. select ID. And select Provide default value. Under that select Content ID from Url. (as shown in following image) enter image description here

2.3.3 Come under FIELDS and add following field: Picture(category: User), Bio(category: User), Links(category: User).

2.3.4 Remove anything which is under the FILTER CRITERIA. Save it. Your final views setting page will be looks like this,

enter image description here

3. Add the created block: Go to Structure>Block> and under first sidebar add this block.

4. Block visibility setting: Now, till this step, everything works fine, but these blocks are not visible to Anonymous user, And to set that, Go to Again go to views setting as shown in just above image, under BLOCK SETTING > Access click permission and select none option, and save. Now, this block will be visible to all users.

Output Image: I have reprocessed this above mentioned process in my Drupal 8 trial site and you can see in following image, with all Author info. on only page which has been authored by that author.

enter image description here

3

Create a new View, of Show: users and checkmark block

enter image description here

Add the fields you want, user pic, user name, etc...

Under Advanced, Add CONTEXTUAL FILTER of User ID with these settings:

enter image description here

Your view preview will go blank, which is normal here, since views is not able to get the node author from the view url. The view will show up when you go to the page/node where you placed the block.

Now create a another user block view. This will be the "Latest Stuff". This time under advanced, add RELATIONSHIP of Content authored

Add your title field and other fields you want.

Use same contextual filter as the 1st view.

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.