Limit tags on content type and content age

Created on 2 July 2025, about 2 months ago

Problem/Motivation

Tags are sourced in content types. In some cases we may have various content types that use the same taxonomy/vocabulary but we don't want all of these types to contribute to tags level force. also, we may want to limit such contribution to only recent content. In this case we need to limit the tags query on content types and on content age.

Steps to reproduce

Proposed resolution

  • In module settings and in block settings alter form to add fields for a content_types array and content_age in days
    $content_types = array('content_type_1', 'content_type_2', 'content_type_3');
    $content_age = time() - (240 * 24 * 60 * 60); // a week, 7 days
    
  • Change TagsServiceInterface to
    public function getTags(array $vids, $content_types, $content_age, $steps = 6, $size = 60, $display = NULL);
  • Change tagService.php getTags function from
    //public function getTags(array $vids, $steps = 6, $size = 60, $display = NULL){
    to
    public function getTags(array $vids, $content_types, $content_age, $steps = 6, $size = 60, $display = NULL) {
  • Add
    implode($content_types),
    $content_age, // Difficulty: set cache on daily or weekly basis instead of seconds

    in $cache_name

  • Add
    $query->condition('n.type', $content_types, 'IN');
    $query->condition('n.created', $content_age, '>');
    

    to $query

  • Change TagcloundsPageChunk.php to
    ->getTags($vocs, $content_types, $content_age, $config->get('levels'), $config->get('page_amount'));
  • Change TagcloundsTermsBlock to
    ->getTags($vocs, $content_types, $content_age, $config->get('levels'), $config->get('page_amount'));
  • and change function parameters everywhere where getTags() is called.

Remaining tasks

User interface changes

API changes

Data model changes

Feature request
Status

Active

Version

2.0

Component

Code

Created by

🇫🇷France erwangel

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024