The Taxonomy Custom Controller module is a default Taxonomy Term entity canonical controller override with event.
It will help you to subscribe to event and change content of term page. You can change it for specific vocabularies, or specific term with conditions you want!
USAGE
Simple example:
/**
* Provides subscriber for term page build.
*/
class TermPageBuildSubscriber implements EventSubscriberInterface {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
return [
TaxonomyCustomControllerEvents::PAGE_BUILD => 'onTermPageBuild',
];
}
/**
* Reacts on term page build.
*
* @param \Drupal\taxonomy_custom_controller\Event\TermPageBuildEvent $event
* The event.
*/
public function onTermPageBuild(TermPageBuildEvent $event) {
$taxonomy_term = $event->getTaxonomyTerm();
if ($taxonomy_term->bundle() != 'tags') {
return;
}
// Adds term description on top of the default views.
$build = [];
if (!$taxonomy_term->get('description')->isEmpty()) {
$build['description'] = [
'#type' => 'container',
'#attributes' => [
'class' => ['wrapper-for-custom-added-description'],
],
'description' => $taxonomy_term->get('description')->view(),
];
}
$build['view'] = views_embed_view('taxonomy_term', 'page_1', $taxonomy_term->id());
$event->setBuildArray($build);
}
}
See taxonomy_custom_controller_example module for full example.
SIMILAR PROJECTS
- TVI — does the same thing. The main difference. With TVI you can use only Views and configure it via UI. With TCC you can do whatever you want, but you need to write Event Subscriber.
Project information
Maintenance fixes only
Considered feature-complete by its maintainers.- Project categories: Developer tools, Content display, Site structure
139 sites report using this module
- Created by niklan on , updated
Stable releases for this project are covered by the security advisory policy.
Look for the shield icon below.
Releases
8.x-1.6
released 28 January 2025
Works with Drupal: ^9 || ^10 || ^11
Drupal 11 compatibility
Install:
Development version: 8.x-1.x-dev updated 28 Jan 2025 at 06:25 UTC
