0

Metadata (publication date, author's name...) is normally displayed in the "Content" part between the "articles" tags. I have created a new region "titre d'article" in which I would like them to be displayed with the title of the article.

my info.yml file I was able to add the title block when the blocks were formatted. For metadata, I created a "Post metadata" view with a "custom text" field to display them. Post metadata view with bloc But when I create a block with this view and add it to my region, it displays metadata for all published articles when it should display for the read-only article. my block layout page article displayed in browser I don't know what I'm doing wrong. Yet I had already done it and it worked. I have to do it again because I'm going to lose the data from my old computer.

So basically, I want to hide or delete the default position of the metadata (that I can do easily) and display them in a custom div created using a region.

Please tell me if there's any mistake in what I did. Or if there's another way to do it more simply, I'd be delighted.

Thanks to help me

0

"Read-only" usually means a file or an item that cannot be changed/edited, you can only view it. I'm guessing what you actually mean is "current, the one being viewed right now".

You have to add a contextual filter to your Views that would filter the results to only the node you're currently viewing.

Here are the steps to configure Views to show only the current node's results:

  1. Expand the Advanced area in your Views
  2. Under Contextual filters click on Add
  3. Add the ID filter from the Content Category and configure it: When the filter value is NOT available
    Provide default value
    Content ID from URL
    When the filter value IS available or a default is provided
    Specify validation criteria
    Content
    Article
    Hide View if the argument doesn't validate, or some other options that make sense to you.
  4. Place the Block on article pages in your theme region (your have this already), adjust Node from URL and other Block options.

The Views Block will only show on article pages, and it will only display output related to the current node.

  • Thank you very much @prkos. You solved my issue. I didn't know anything about this "advanced" column. But it's weird, like I said, I've already succeeded in the past. But I hadn't done any of that. And yet it had worked. Now I don't know how I got there at all. In any case, thank you, this solution also solves my problem. Thank you for responding so quickly. – Worksfather May 28 at 20:22
  • It's worked like that since I can remember, so you probably had it set up that way, but since your Advanced column is collapsed you forgot that anything was changed there. If you still have a site with that "old" way you can look it up and check. – prkos May 28 at 20:42
  • Okay, I get it. Thank you. – Worksfather May 28 at 21:01
0

I think using views for displaying a part of node fields on the node page is not the best way to do it.

I would create a page template and a node template for Article content Type and display the needed fields there.

You can find more about Drupal 8 theming here

Also, training materials by Drupalize.me are fantastic. Let's do it the proper Drupal way.

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.