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:
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.
Each government agency offering a job on the site should have its own page with a logo. In addition, each job posting should clearly show which agency is offering the job.
In our next exercise we’ll create a new content type called “Agency”. The content type will include an area to upload the agency’s logo.
When setting up media uploads for content types, consider these two important settings:
File path settings
When you add a field for file type, you’ll configure the “file directory”. The file directory settings are hard to change once they’ve been set up, so make sure you consider the settings carefully. The file directory will help you keep track of a file’s location and why they were uploaded.
Keep your directories organised as you go by adding a file path for each new file field.
Public versus private files
Go to Configuration → Media → File system
You’ll find the default global directory for file uploads in this area of the admin interface. Files in this area are public, meaning anyone with the link can view/download them. If you’ve got private files you’d like to secure, see this tutorial
The Agency name is there, and it's a link. We configured it in one of the previous steps.
Name | Agency |
---|---|
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