Building Blocks: Creating a custom sorted list of people for your directory
The ability to have fine-tuned lists of people within a specific person Type category has been a long-sought request from the SiteFarm user community. We had hoped to find a Drupal community module capable of offering the kind of secure, stable functionality that would meld well with the SiteFarm platform, but the module candidates we've considered are either not ready yet or present user-interface challenges or functionality issues that make us reluctant to add them in.
Instead, we've hit on a solution we hope will work well for you since it utilizes existing features in SiteFarm. We're going to show you how you can create a custom Person List block in the same mold as the other custom blocks available to you in the Custom Block Library. This means:
- the block will appear in the Custom Block Library list just as the Marketing Highlight block and other blocks do
- you'll be able to create more than one instance OR reuse a single block created from the Person List block in multiple
- the same permissions set for the other blocks will apply to this one and Editors will be able to create, edit, place, and delete them as usual
Caveats for this project
- You must have the Site Builder role in order to create this block, though once created, Site Managers and Editors will be able to use it the same way they use other items in the Custom Block Library.
- If you have more than one site in which you would like to use this block, you will have to create a unique instance on each site
- The contents of the block—however many people you list—will be visible to Google search and other search engines, but the Search/Filter block normally associated with the People directory will not see them because search/filter is associated with View content (default output), not your new block content.
- When attached to your /people page, this block will statically live on the page and be independent of the pagination element on the bottom of the page if you have more than ten people in your directory
Create the Person List block (Site Builder role required)
- Navigate to Shortcuts » Blocks » Custom Block Library tab » Block Types tab.
- Click the + Add custom block type button.
- Provide a label: Person List
- Provide a description: A custom list of people content you can drag 'n' drop into your preferred order
- Click Save to finish, after which the system will return you to the Custom block types list.
Setting the Fields
- Locate Person List and click its Manage Fields button.
- By default, the block comes with a Body field. Use the Operations button to delete the Body field.
- When the system asks you to confirm the deletion, click the Delete button to continue.
- When you return to the Manage Fields screen, click the + Add fields button.
- On the Add Field screen, use the menu under Add a new field to select Reference: Content.
- A label field will appear. Type in "Person" and then click the Save and continue button.
- The new Person screen will appear. Change the Allowed number of values from Limited: 1, to Unlimited.
- Click the Save field button.
- On the Person settings for Person List page, scroll to the bottom and locate the Reference type » Content type section. Check the box for the Person content type.
- Click the Save settings button.
Manage form display tab
- On the Manage form display page use the pull handle on the left side to drag the Person field listing underneath the Block description field.
- Click Save to finish.
Manage display tab
- On the Manage display page, update the Person field display settings to:
- Label: from Above to - Visually hidden -
- Format: from Label to Rendered entity
- View mode: from Default to Teaser
- Click the Update button
- Click the Save button to finish.
- Your block is now created, configured, and ready for use.
Use your new Person List block
- Whichever people are going to be added to your specific person list, you should first edit their individual Person pages and, under Additional Options » Promotion Options, check the box to Hide from Directory to avoid having the person show up twice on your page.
- You can either create the block through the Custom Block Library path or use the Place block button option.
- From your Custom Block Library, select the Person List block from the list.
- Provide the following information:
- Block description (title) - this will be the Person type group you would have assigned your people
- People's names as entered previously in a Person content type. Each field will autocomplete the name to assist you in your selection
- Continue to use the Add another item button until you have enough fields to add the select group of people you need to manually organize
- If necessary, use the pull handles on the left side to drag 'n' drop the names into the order you want them to display on the page
- Click Save to continue.
- On the Configure block page, scroll down and locate the Visibility | Pages field. Enter in /people so the block will appear on the correct page.
- Assign the correct region. Please note that if you add it to the Content region, you may need to adjust the block's position in the Block Layout page if you want it to appear over top of the default people listing.
- Click Save block to finish and review your work.
Example of Final Output
In the image on the left, you'll see an example of a People directory that includes a custom Person List block titled "Executive Group." Without this block, the three people included would have been included in the original, default directory, but in alphabetical order by last name instead of in our preferred order with the Executive Director, Regina Tyson, listed first. Likewise, we can say in our scenario that Sara Knowles has seniority in the Assistant Director position and we want her listed next followed by Dennis Jones.
The remainder of the regular listing follows after, denoted by the visual break between our Executive Group block (custom Person List block) and the beginning of the section for Principal Investigators from the regular People directory that comes standard in your SiteFarm site.