BySubjectController
in package
Handles displaying nodes categorized by their associated subject taxonomy term.
This controller fetches nodes that are tagged with taxonomy terms representing subjects. It organizes these nodes by their subject taxonomy term and displays them in an accordion format. This is particularly useful for creating subject-based navigation or content grouping within the site.
Table of Contents
Methods
- bySubject() : array<string|int, mixed>
- Constructs a render array to display nodes by subject in an accordion layout.
Methods
bySubject()
Constructs a render array to display nodes by subject in an accordion layout.
public
bySubject() : array<string|int, mixed>
Retrieves nodes tagged with subject taxonomy terms from the database, organizes them by their respective terms, and then formats this list for display in an accordion. Each node is presented as a link within the accordion, grouped under its corresponding subject term. This method leverages a helper function to perform database queries and another to construct the accordion.
Tags
Return values
array<string|int, mixed> —A render array for Drupal, containing the accordion structure with nodes grouped by subject taxonomy terms. Each group in the accordion represents a subject, with the nodes listed as clickable links.