LogoLogo
  • GovCMS8 Site Building Training Manual
  • Contributing and Feedback Guide
  • Software and module requirements
  • UNIT 1: FUNCTIONAL ANALYSIS
    • Overview
    • Layout of a GovCMS page
    • Regions in GovCMS
    • Planning your site
    • About our client
    • Understanding requirements
    • Audience analysis
    • User (visitor) personas
    • Define user stories
    • Roles and Permissions
      • Exercise 1.1: Configure account settings
    • Blocks in GovCMS
      • Exercise 1.3: Place Welcome message block
    • Site navigation
    • Footers
      • Exercise 1.4: Build the related links menu
      • Exercise 1.5: Assign the related links menu block to a region
      • Exercise 1.6: Configure the related links menu block
      • Exercise 1.7: Rearrange the main menu
    • Theme settings
      • Exercise 1.8: Change the logo
      • Exercise 1.9: Create a friendly error page
    • Unit 1 Summary
  • UNIT 2: DESIGNING AND PLANNING CONTENT
    • Designing and planning content
      • Exercise 2.1: Compare content types
    • Planning your site structure
    • Planning data entry and display
    • Discussion
      • Exercise 2.2: Design a content type in minutes
      • Exercise 2.3: Create a content type
    • Add and configure fields
      • Exercise 2.5: Modify an existing field
      • Exercise 2.6: Add a custom text field
      • Exercise 2.7: Review the field list report
    • Manage form display
      • Exercise 2.8: Testing content types
    • Unit 2 Summary
  • UNIT 3: MANAGE MEDIA
    • Manage Media
    • Customise image display with image styles
    • Review configuration of image media display
      • Exercise 3.1: Example use of image styles
      • Exercise 3.2: Add and configure a media field
      • Exercise 3.3 (Challenge): Change image size
    • Unit 3 Summary
  • UNIT 4: TAXONOMY - CATEGORISING CONTENT
    • Taxonomy - Categorising content
      • Exercise 4.1: Add new Vocabulary
      • Exercise 4.2: Add Taxonomy field to content types
    • About input options
      • Exercise 4.3: Add fields to content types
      • Exercise 4.4: Test the new vocuabulary
    • Editorial considerations
    • Prepare documentation for new staff onboarding
    • Content creation forms
    • Unit 4 Summary
  • UNIT 5: TEXT FORMATS AND RICH TEXT
    • Text formats and rich text
      • Exercise 5.1 (Optional): Set up the Rich Text editor
      • Exercise 5.2 (Challenge): Create a new text format
    • About cross-site scripting
    • Text formats
    • Unit 5 Summary
  • UNIT 6: CONTENT LISTING WITH VIEWS
    • Content listing with Views
      • Exercise 6.1: Build the employment news view
    • Views - Part 2
      • Exercise 6.3: A customised News and Media page
      • Exercise 6.4: Reuse a Views template
    • Related content by term
      • Exercise 6.5: Make a list of States/Territories block
      • Exercise 6.6: Build the related content block
      • Exercise 6.7: Configure data field and Event content type
      • Exercise 6.8 (Challenge): Extend Content type
      • Exercise 6.9: Modify an event listing for future dates
    • Customize the content administration experience
      • Exercise 6.10: Administration with View bulk operations
    • Unit 6 Summary
  • UNIT 7: URL ALIASES
    • URL Aliases
      • Exercise 7.1: URL aliases - Patterns
    • URL Redirects
      • Exercise 7.2: Configure redirects
      • Exercise 7.3: Breadcrumbs
    • Menu check
    • Unit 7 Summary
  • UNIT 8: SITE BUILDING EXERCISES
    • Site building exercices workshop
    • Extend content types with new fields
      • Exercise 8.1: Add an external link field
    • Agency reference link
      • Exercise 8.2: Create Agency References
    • Job list dropdown filter
      • Exercise 8.3: Configure the job listing
      • Exercise 8.4: Agency logo in Job Posting view
      • Exercise 8.5: Challenge exercises
    • Discussion
    • Views contextual filters
      • Exercise 8.6: Add About author block to News article
    • Further discussion and exercices
    • Employee list and custom profiles
      • Exercise 8.7: Set up profile fields
      • Exercise 8.8: Create a list of users
      • Exercise 8.9: Edit the existing view to filter out roles
      • Exercise 8.10: Create a custom layout
      • Exercise 8.11 (Challenge): An image gallery
    • Unit Summary
    • Discussion
  • UNIT 9: SEARCH AND RELATED CONTENT
    • Search and related content
      • Exercise 9.1: Explore the default search
      • Exercise 9.2: Set up Job posting content type display in global search
      • Exercise 9.3: Create new search page with Search API
      • Exercise 9.4: Add fields to the index
      • Exercise 9.5: Extend the search with Facets
    • Unit Summary
  • UNIT 10: SITE PERFORMANCE
    • Overview
    • Planning for Peformance
    • Define Goals and Requirements
    • Review current issues and bottlenecks
    • Other performance considerations
    • Unit 10 Summary
    • Glossary of terms
    • Appendices
Powered by GitBook
On this page
  • Prepare the site
  • Add a new View
  • Add fields to the View
  • Make display dependent on author of content (contextual filter)
  • Check the preview
  • Place the block and test
  • Review Panelizer content configuration

Was this helpful?

Edit on GitHub
Export as PDF
  1. UNIT 8: SITE BUILDING EXERCISES
  2. Views contextual filters

Exercise 8.6: Add About author block to News article

PreviousViews contextual filtersNextFurther discussion and exercices

Last updated 1 year ago

Was this helpful?

In this exercise we’ll create an author block.

Prepare the site

To maximise this exercise, make sure user accounts have profile images. Out-of-the-box, GovCMS does not have a profile image available. Let’s add it.

  1. Navigate to Configuration → People → Account settings → Manage fields. You’ll notice that this interface is exactly the same as for content types.

  2. Add an Image field, using your previous experience adding fields. Make the Image field match the following criteria:

    • Field type: Reference > Image

    • Label: Profile Image

    • Machine name: field_profile_image

    • Upload destination: Public files

    • Default image: Upload a default generic profile image (you may Google for “user profile placeholder”)

    • Allowed number of values: 1

    • Required field: yes

    • File directory: profile_photos

    • Minimum image resolution: 150x150px

    • Maximum upload size: 1MB

  3. Configure Manage Display:

    1. Place the Profile Image above all fields

    2. Hide the field label - Visially Hidden

    3. Apply Image style: Medium (220 x 220)

  4. Save your changes.

  5. Add images to the profile of some website users. Alternatively use the Generate users function (Configuration → Generate → Generate users).

  6. Change the authors of existing content so we have a variety of authors. Edit the “Authoring information” tab in the existing News and Media and Job postings.

Alternatively use the Generate content function (Configuration → Generate → Generate content). Select News and Media, Job posting content types.

Note: If the Generate content function was used, make sure you publish your News and media posts. Remember, they’re not published by default due to the Moderation workflow in place.

Add a new View

  1. Go to Structure → Views → Add View.

  2. Use the following information to fill out the form:

    • View name: About the author

    • Show “Users” sorted by “Unsorted”

    • Select “Create a block”

    • Display format - Unformatted list of Fields.

    • Change Items per block to 1. Use the defaults for everything else (ensure the settings are as shown in the image below)

  3. Click Save and edit

This loads the full Views editing screen. The screenshot below correlates to the steps outlined in the next sections.

Add fields to the View

Notice the “Advanced” options available in Views.

  1. In the left column, find and edit fields by clicking Add.

  2. Select Profile image (User).

  3. Click Add and configure fields.

  4. On the next configuration popup screen, apply the Image style Medium (220x220).

  5. Make the image linking to Content.

  6. Apply your changes.

  7. Rearrange the User: Profile Image field to stay above the User: Name field

Make display dependent on author of content (contextual filter)

  1. On the right-hand side, click Advanced to expand the settings.

    • Next to Contextual filters click Add.

  2. In the next screen, type “ID” into the search field.

    • Select “User ID”.

    • Click Add and configure contextual filters.

  3. In the next screen, select “Provide default value”. This opens extra options.

    • Type: “User ID from route context”

    • Toggle “Also look for a node and use the node author” to on.

  4. Select Specify validation criteria under “When the filter value IS available or a default is provided” and select User ID as Validator.

  5. Click Apply.

  6. Click Save to save the view.

Check the preview

When you check the preview you’ll notice nothing is displaying. To fix this:

  1. Type 1 and click Update preview. This pulls in the profile of user/1.

  2. Click Save at the top of the Views editing screen.

Place the block and test

Now we can configure the block to display on News and Media articles. The News and Media content type is set up by default to use Panelizer view. The Panelizer view replaces the default GovCMS page layout and provides a way to build a “layout within layout”.

Check the Manage Display page of the News and media content type - go to Structure → Content types → News and media - Manage Display.

You’ll see that the page has multiple View modes activated. The Full content view mode overrides the page display for our content type. Let’s explore it.

Notice that this display configuration page looks completely different to our Job posting content type. Instead of fields and display modes we see Displays here. By default, the Sidebar right display is used to render our News and Media content.

You may also notice that the Content Editors are allowed to select which display to use. This flexibility provides alternative display options for showing our News and Media articles, but introduces some extra complexity in configuring it.

Review Panelizer content configuration

Let’s review how the Panelizer content is configured. We’ll practice placing the Content Author block in our News and Media articles.

  1. Click the Edit button in the Sidebar Right (2:1) row

  2. Click the Content vertical tab on the left:

  3. Explore the Content page. See how it has their own regions defined

  4. Click the Add new block button at the top of the page

  5. Under the Lists (Views), locate the block we prepared earlier:

  6. Select Sidebar region and Add block

  7. Position the About the author block below other blocks within the Sidebar region

  8. Click Update and Save

Test it by navigating to a published News and Media article. You may update the content of the page and the Authoring information, to check how the display changes.

Logout and test: Can anonymous users see the block?

Image of Authoring information
Image of full Views editing screen
Image of News and media Manage display
Image of New field settings
Image of New field settings
Image of Field settings
Image of Field settings
Image of View create page
Image of Provide default value
Image of General Settings - Content
Image of Content page Regions
Image of About the Author lists view
Image of Add block to Sidebar
Image of Position block