Exercise 8.2: Create Agency References
Last updated
Last updated
Content Reference is a useful tool in GovCMS. It helps you create new relationships between content. There are many ways to leverage this connection with Views. For example, when you’re viewing an agency page, you could show which jobs “back reference” to that agency.
Using what we’ve covered so far on content types, create a new content type using these settings:
Description
A government agency listing jobs or services on this site.
Title field label
Agency name
Publishing options
NOT Promoted to front page
Display settings
Don’t Display author and date information.
Menu settings
No menu
Click Save and manage fields.
Note: Make sure you check permissions, allowing Content Authors to create agencies.
We’re now going to add the Image field to the agency content type. When adding the field, make sure you also configure the form display and the display of the field. Use the following settings:
Label: Agency Logo
Field name: field_agency_logo
Field type: Media Reference (not Dynamic media reference)
Number of values: 1
Required: Leave unselected
Help text: “If available, please upload a logo for this agency.”
Media type: Image
Click on the Manage form display tab. Select Entity browser from the Widget dropdown, then click the cog icon next to the Agency logo field.
Adjust the settings as shown in the screenshot below:
When finished, click the Update button and then Save the Manage form display page.
Finally, we’re going to add a references field for job postings.
Go to Structure → Content types → Job posting and click the Manage fields link.
Add a new field using these settings:
Type: Reference → Content
Label: Agency
Field name: agencyref (click to edit the machine name)
Content type: Agency
Sort by: - None -
Click Save settings.
You’ll also need to configure the form display. Use the Select list widget for the Agency field. Note: You can also move the Agency field on the form so it’s above the Job description field.
You’ll also need to configure the display. Set the Agency field to display as a link.
Your job posting fields will now look something like the screenshot below.
You may rearrange any new fields we’ve added and bring them above the Job description field.
Now that you’ve added the new fields, it’s time to try them out.