LocalGov Drupal Docs
Overview
  • Developers
  • Content designers
  • Designers
  • Contributing
  • Credits System
  • Accessibility
  • Governance
Microsites
Main site
GitHub
Overview
  • Developers
  • Content designers
  • Designers
  • Contributing
  • Credits System
  • Accessibility
  • Governance
Microsites
Main site
GitHub
  • For Developers
  • Getting started
    • Drupal requirements
    • Working with Lando
    • Working with DDEV
    • Debugging with Xdebug
    • Working with Gitpod
  • General configuration
    • Content types
    • Custom modules
    • Image styles
    • Media types
    • Paragraph types
    • Taxonomies
    • User roles
  • Features
    • Services: Technical
    • Alert banners: Technical
    • News: Technical
      • Introduction
      • Requirements
      • Permissions
      • Installation
      • Basic Configuration
      • Managing content
      • Advanced Configuration
      • Theming
      • Useful links
      • Contributors
    • Directories: Technical
    • Location Geo: Technical
    • Subsites: Technical
    • Workflows: Technical
  • Theme
    • LocalGov Base
    • Regions
    • LocalGov Theme (Deprecated)
    • Skeleton theme (Deprecated)
    • Admin theme (Deprecated)
  • Testing
  • Development workflows
    • Installing and deploying a LocalGov Drupal site
  • Hosting
    • Hosting a LocalGov Drupal site
    • Hosting LocalGov Drupal on Azure
  • Release statuses
    • Release statuses
  • Security
    • Best practice guidance
    • Single Sign-On
  • Quality standards
    • Quality standards: Accessibility
    • Quality standard: Documentation
    • Quality standard: Testing
  • How-tos
    • How to use Gitpod to test modules in the browser

News: Technical

  • Introduction
  • Requirements
  • Permissions
  • Installation
  • Basic Configuration
    • General
  • Managing content
    • Usage
  • Advanced Configuration
    • Structured data
    • Search Api & Facets
    • Indexed fields
    • Processors
    • Facets
  • Theming
    • Twig templates
    • Theme suggestions
    • Markup and CSS
  • Useful links
  • Contributors

Introduction

When you enable this feature you will get:

  • News Article content type
  • Newsroom content type
  • News editor role

A single Newsroom is created on installation, which will list all News Articles by default. There will be up to three “featured” News articles listed at the top of the page.

The Newsroom page will display a search and filters block, allowing end-users to filter the list of news by date and category.

If multiple Newsrooms are created the editor will be given the option to choose to associate a News Article with a single Newsroom.

Requirements

Drupal core

  • Drupal 8: >= 8.8
  • Drupal 9: >= 9.0

Drupal modules

dependencies:
  - drupal:datetime
  - drupal:field
  - drupal:link
  - drupal:menu_ui
  - drupal:node
  - drupal:path
  - drupal:taxonomy
  - drupal:text
  - drupal:user
  - entity_browser:entity_browser
  - entity_reference_facet_link:entity_reference_facet_link
  - facets:facets
  - field_group:field_group
  - link_attributes:link_attributes
  - localgov_core:localgov_core
  - pathauto:pathauto
  - search_api:search_api
  - search_api:search_api_db
  - search_api_autocomplete:search_api_autocomplete
  - schema_metatag:schema_metatag
  - schema_metatag:schema_article

Permissions

By default a person with the news_editor role can publish and unpublish News Articles.

Custom permissions will need to be set up to define which roles can feature News, and create, edit and delete content of the type “Newsroom”.

Installation

This module is part of the LGD distribution, but is not installed by default.

Install as you would normally install a contributed Drupal module.

composer require localgovdrupal/localgov_news

Basic Configuration

By default the search and facet blocks for News are shown in the view mode for the Newsroom, and as blocks on all pages under the news/* path if you have the localgov_theme installed. Alternatively, add, or change the configuration for these three blocks from the Drupal block layout admin page.

General

News Article

Name:
News Article

Machine name:
localgov_news_article

Description:
A stand-alone news article that may also appear in a news listing page.

Menu settings

Available menus:

  • Main navigation

Default menu: none

Simple XML Sitemap

Included: true

Fields
Field nameMachine nameField type
BodybodyText (formatted, long, with summary)
Categorieslocalgov_news_categoriesEntity reference
Datelocalgov_news_dateDate
Imagefield_media_imageEntity reference
Newsroomlocalgov_newsroomEntity reference
Related articleslocalgov_news_relatedEntity reference

Newsroom

Name:
Newsroom

Machine name:
localgov_newsroom

Description:
A page for listing and featuring News Articles.

Menu settings

Available menus:

  • Main navigation

Default menu: <main>

Simple XML Sitemap

Included: true

Fields
Field nameMachine nameField type
TitletitleText
Featuredlocalgov_newsroom_featuredEntity reference

Managing content

Usage

Newsroom

  • A default News '/news' Newsroom will be installed. News Articles by default go into this.
  • It is possible to post more Newsrooms for articles to go into.
  • A Newsroom has a field in which it is possible to select 3 featured News Articles.
  • The Featured News block shows up to 3 featured articles - if there are fewer than 3 explicitly featured News Articles the remainder will be filled by the latest promoted articles (if any).
  • The Article List block will show 10 articles per page, excluding those in the featured block.
  • The limits (3 and 10) can be changed in the localgov_news_list view on the all_news and featured_news displays.

Add News articles. By default:

  • The Categories field uses the LocalGov Topics vocabulary. Edit the field to use alternative or additional vocabularies.
  • Image is a required field - authors can upload a new image or select an image from the media library.
  • Article nodes are not promoted - see the Featured News section below.
  • Article aliases are: [node:localgov_newsroom:entity:url:relative]/[node:localgov_news_datedatehtml_year]/[node:title] thus prefacing the path with that of their Newsroom, followed by year and sanitised title.

Advanced Configuration

Structured data

The Schema.org Metatag module is used to generate structured data for individual News Articles. This is rendered as JSON LD in the <head> element.

eg. creating new entity_types etc etc

Search Api & Facets

On installation there is a new Server created named News, which can be used or replaced. The News Index is indexing Content of type News articles and is set to Index items immediately.

Indexed fields

The fields being indexes are the Rendered HTML output, using the view mode Search index. The following fields are also indexed to provide faceted search, or view configuration

  • Categories
  • Date
  • Newsroom
  • Title

Processors

Entity status, HTML filter, Ignore case, Stemmer, Stopwords, Tokenizer, Transliteration are enabled on all supported fields.

Facets

Facets for Category and Date are provided by default.

Theming

Twig templates

  • field--localgov-newsroom-featured.html.twig
  • node--localgov-news-article--full.html.twig
  • node--localgov-news-article--teaser.html.twig

Theme suggestions

Markup and CSS

Css is defined in the css directory: https://github.com/localgovdrupal/localgov_news/tree/2.x/css

Useful links

  • Git repo
  • Readme
  • Issue Queue

Contributors

  • @danchamp
  • @ekes
  • @finnlewis
  • @stephen-cox
Help us improve this page!
Last Updated: 7/11/2023, 3:03:05 PM
Prev
Alert banners: Technical
Next
Directories: Technical