Extra Block Types (EBT) - New Layout Builder experience❗

Extra Block Types (EBT) - styled, customizable block types: Slideshows, Tabs, Cards, Accordions and many others. Built-in settings for background, DOM Box, javascript plugins. Experience the future of layout building today.

Demo EBT modules Download EBT modules

❗Extra Paragraph Types (EPT) - New Paragraphs experience

Extra Paragraph Types (EPT) - analogical paragraph based set of modules.

Demo EPT modules Download EPT modules

Scroll

1.9 Views: News feed on Drupal

05/08/2019, by mikhail

Views module is one of the most popular modules. It allows you to display any data you want News, Articles, Comments, Taxonomy terms in the form of blocks, pages, RSS feeds, CSV files, XML files, and in many other formats. And finally, in Drupal 8 Views in the core! Now it does not need to be installed, Views is in the standard installation.

Let's include on Views and start displaying the data.

Create the content type News.

Drupal 8 news

Now we can create news on the site.

Add a picture to the content type News. To do this, go to the Manage Fields tab. You can use an existing field_image field, which is already used in Articles.

Add field

Let's create some news so that there is something to output through Views:

menu

Now we can create our first View. Go to Menu - Structure — Views:

menu

On the Views page, we create a new view:

views creation

Now let's fill in the form of creating a new view in order. First, write the name of the view, you can also specify the machine name of the view. We write the name view News, choose what we will display content type News. Also, leave Newest first to display:

Views adding

Next, select the Create a page, put a check mark. Next, enter the title of the new News page. Next, enter the address at which the news page will be, I wrote news. We will output the Unformatted list (using div tags) in the standard way, we will output it with teasers (brief contents of the nodes, we talked about this in previous lessons).

If there will be a lot of news, more than 10, then we need a page navigator, by default it is worth displaying 10 pieces per page, and we can see the rest of the news by following the navigator links. So leave the settings of the navigator as is Use a pager.

view using pager

Then we can choose in which menu to display a link to our new news page. I chose main navigation, this is the main menu in the header of the site. And enter the name of the News link. Save.

views save

After that, we will have a page for further view editing. Here we can no longer edit anything and go out to see our news page.

news

let's make a news block with 3 latest news and a link to the news page. Create another view. We call it the News block, we select the news output.

views block

This time we will not display a page, but a block. We will output unformatted list, fields, according to 3 news. Now save our view. In the block, we will not use pager. Now we can continue to edit our view.

Views fields

Here we have many settings Title, Format, Fields, filter criteria , Sort criteria , Block settings,Header, Footer, no results behavior, Pager and other advanced settings. In the following lessons, we will analyze each of the items in detail, while let's add another field for the publication date, higher than the headline of the news.

views add fields

Now you need to find the desired field, namely Authored on. To do this, write Authored on in the field search and check the box to display the field. After that we save changes.

authored on

Next, you need to set the date format, I also unchecked the label output:

drupal views remove the label

The publication date is not the date when the content was created, you can display the creation date separately.

The publication date is the time when the content was saved with the checkmark “published”.