This guide provides instructions on setting up a Drupal site with a "Staff Recommend" content type, faceted browsing using two vocabularies (Audience and Recommend Tags), and configuring various site settings.
- A fresh Drupal installation.
- Basic knowledge of Drupal administration.
Install the following modules:
- Search API
- Facets
You can install these modules via the Drupal UI or using Drush:
drush en search_api facets restui -y- Navigate to
Structure -> Taxonomy -> Add vocabulary. - Create two vocabularies: "Audience" and "Recommend Tags".
- Navigate to
Structure -> Content types -> Add content type. - Create a content type named "Staff Recommend".
- Add fields as required, including entity reference fields for the "Audience" and "Recommend Tags" vocabularies.
To import taxonomy terms:
- Navigate to
Structure -> Taxonomyand select the relevant vocabulary (e.g., Audience). - Click on
Add term. - Enter the details for the term and save.
Repeat the process for each term you want to add to the vocabularies.
Example terms:
- For "Audience": Adults, Teens, Children
- For "Recommend Tags": Must Read, Staff Pick
To include iframe tags in Views, you'll need to modify the Xss.php file in the Drupal core. This is not a typical practice and is generally discouraged. Proceed with caution and consider the potential risks.
-
Locate the
Xss.phpFile:- Find the
Xss.phpfile in your Drupal installation. It's typically located incore/lib/Drupal/Component/Utility.
- Find the
-
Modify the
Xss.phpFile:- Open
Xss.phpin a text editor. - Find the array of allowed HTML tags. This is usually a static function named
getHtmlTagList(). - Add
'iframe'to this array. - Save your changes.
Example:
protected static function getHtmlTagList() { return [ // Existing tags... 'iframe' => [], // ...other tags ]; }
- Open
-
Clear Drupal's Cache:
- After making changes, clear Drupal's cache to ensure your changes take effect.
- Backup: Always backup the file and your database before making any changes.
- Updates: Remember that updating Drupal core will overwrite your changes. You'll need to reapply them after each update.
- Security: Allowing additional tags, especially
iframe, can increase security risks. Ensure that only trusted users have the ability to use these tags. - Alternative Solutions: Consider using modules that allow iframe embeds securely, such as the 'Media' or 'Entity Embed' modules, as a safer alternative to editing core files.
For path alias patterns:
- Navigate to
Configuration -> Search and metadata -> URL aliases -> Patterns. - Configure patterns for content and taxonomy terms as desired.
Example pattern for "Staff Recommend" nodes: /staff-recommend/[node:title]
- Navigate to
Configuration -> Search and metadata -> Search API. - Add a new index for the "Staff Recommend" content type.
- Add necessary fields to the index, including reference fields for "Audience" and "Recommend Tags".
- Navigate to
Configuration -> Search and metadata -> Facets. - Create new facets for "Audience" and "Recommend Tags".
- Configure facet display settings.
- Navigate to
Structure -> Views -> Add view. - Create a view that shows "Staff Recommend" content.
- Integrate facets with the view.
Using either the Block layout or Layout Builder:
- Place your facet blocks in the desired regions on your site.
After setting up, create at least two "Staff Recommend" items and assign different terms from your vocabularies. Example entries:
- Item 1: Title: "Summer Reads", Audience: Adults, Tags: Must Read
- Item 2: Title: "Youth Adventure", Audience: Teens, Tags: Staff Pick
Index these items and test the facets on the created view page.
- Re-index your content after making changes to the fields or configurations.
- Test the setup thoroughly.
- Adjust configurations based on test results.
This guide assumes familiarity with Drupal's administrative interface and basic site-building concepts. Adjust steps as necessary to fit your specific Drupal version or requirements.