Skip to content

Commit

Permalink
[FEATURE] add new option for tag filter operator
Browse files Browse the repository at this point in the history
  • Loading branch information
mesosa committed Jul 10, 2024
1 parent 2a21d8c commit ff4d016
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"filter.default.tag_filter" : {
"message" : "AND",
"description" : "",
"placeholders" : null
},
"blog_components.component.default" : {
"message" : "Image",
"description" : "",
Expand Down Expand Up @@ -179,6 +184,66 @@
"description" : "",
"placeholders" : null
},
"filter.default" : {
"message" : "",
"description" : null,
"placeholders" : null
},
"filter.help_text" : {
"message" : "",
"description" : null,
"placeholders" : null
},
"filter.inline_help_text" : {
"message" : "",
"description" : null,
"placeholders" : null
},
"filter.label" : {
"message" : "Filter",
"description" : null,
"placeholders" : null
},
"filter.placeholder" : {
"message" : "",
"description" : null,
"placeholders" : null
},
"filter.tag_filter.choices.AND" : {
"message" : "Match all tags (AND)",
"description" : null,
"placeholders" : null
},
"filter.tag_filter.choices.OR" : {
"message" : "Match any tag (OR)",
"description" : null,
"placeholders" : null
},
"filter.tag_filter.default" : {
"message" : "AND",
"description" : null,
"placeholders" : null
},
"filter.tag_filter.help_text" : {
"message" : "",
"description" : null,
"placeholders" : null
},
"filter.tag_filter.inline_help_text" : {
"message" : "",
"description" : null,
"placeholders" : null
},
"filter.tag_filter.label" : {
"message" : "Tag filter",
"description" : null,
"placeholders" : null
},
"filter.tag_filter.placeholder" : {
"message" : "",
"description" : null,
"placeholders" : null
},
"general_heading.display.choices.display-1" : {
"message" : "Heading display 1",
"description" : "",
Expand Down Expand Up @@ -3263,5 +3328,15 @@
"message" : "",
"description" : "",
"placeholders" : null
},
"tag_filter.choices.value 1" : {
"message" : "Label 1",
"description" : null,
"placeholders" : null
},
"tag_filter.choices.value 2" : {
"message" : "Label 2",
"description" : null,
"placeholders" : null
}
}
}
30 changes: 29 additions & 1 deletion theme/modules/blog-recent-by-tag.module/fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -2503,6 +2503,34 @@
"layout" : "basic-grid",
"number_of_posts" : 3
}
}, {
"id" : "94b44943-196c-d769-408b-7fa720d7bdc4",
"name" : "filter",
"display_width" : null,
"label" : "Filter",
"required" : false,
"locked" : false,
"children" : [ {
"id" : "a82e859b-223f-d469-b694-3f9d69133d34",
"name" : "tag_filter",
"display_width" : null,
"label" : "Tag filter",
"required" : false,
"locked" : false,
"display" : "select",
"choices" : [ [ "AND", "Match all tags (AND)" ], [ "OR", "Match any tag (OR)" ] ],
"multiple" : false,
"reordering_enabled" : true,
"preset" : null,
"type" : "choice",
"default" : "AND"
} ],
"tab" : "CONTENT",
"expanded" : false,
"type" : "group",
"default" : {
"tag_filter" : "AND"
}
}, {
"id" : "edda9167-14cd-611b-b450-57be5e63e12f",
"name" : "blog_components",
Expand Down Expand Up @@ -2565,4 +2593,4 @@
"component" : "Description",
"show" : true
} ]
} ]
} ]
2 changes: 1 addition & 1 deletion theme/modules/blog-recent-by-tag.module/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
"module_id" : 96451595972,
"label" : "Blog recent by tag",
"is_available_for_new_content" : true
}
}
3 changes: 2 additions & 1 deletion theme/modules/blog-recent-by-tag.module/module.html
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@

<div class="blog-recent-by-tag-module__article-container">
{% set posts_amount = module.layout.number_of_posts %}
{% set init_recent_by_tag_posts = blog_recent_tag_posts(group.id, content.tag_list, posts_amount + 1, "AND") %}
{% set filter_operator = module.filter.tag_filter %}
{% set init_recent_by_tag_posts = blog_recent_tag_posts(group.id, content.tag_list, posts_amount + 1, filter_operator) %}
{% set recent_by_tag__posts = init_recent_by_tag_posts|selectattr("id", "!=", content.id) %}
{% if recent_by_tag__posts|length > posts_amount %}
{% do recent_by_tag__posts.pop(posts_amount) %}
Expand Down

0 comments on commit ff4d016

Please sign in to comment.