Bricks 中文文档:bricks/screen_conditions/scores

📄 原始资料  |  展开查看原始 JSON(bricks-screen_conditions-scores.json){ “name”: “bricks/screen_conditions/scores”, “kind”: “filter”, “url”: “https://academy.bricksbuilder.io/developer/hooks/filters/filter-bricks-screen_conditions-scores/”, “scraped_at”: “2026-08-29”, “hook_name”: “bricks/screen_cond…

📄 原始资料  |  展开查看原始 JSON(bricks-screen_conditions-scores.json)
{
  "name": "bricks/screen_conditions/scores",
  "kind": "filter",
  "url": "https://academy.bricksbuilder.io/developer/hooks/filters/filter-bricks-screen_conditions-scores/",
  "scraped_at": "2026-08-29",
  "hook_name": "bricks/screen_conditions/scores",
  "description": {
    "en": "Bricks selects the template & theme style for a specific page according to the conditions you’ve defined. Internally this is done via a scoring system from 0 to 10. 0 is the least specific. 10 being the most specific (e.g. specific post ID). For each template/theme style condition that could apply to a certain context, the template/theme style earns a specific score. After analyzing all templates/theme styles, Bricks chooses the one with the highest score. If you need to add new template conditions using the filter builder/settings/template/controls_data or bricks/theme_styles/controls for theme styles, you then need to hook into the scoring logic to score the templates/theme styles based on the custom conditions. This is where the bricks/screen_conditions/scores filter comes in handy, like so: Example 1: Add the score for a specific author role in an author archive template After adding the control using the builder/settings/template/controls_data (check example 1), we now need to hook in bricks/screen_conditions/scores to score the template based on the condition, like so:",
    "zh": "Bricks 根据你定义的条件为特定页面选择模板和主题样式。内部通过 0 到 10 的评分系统完成。0 是最不特定的,10 是最特定的(例如特定的文章 ID)。对于可以应用于特定上下文的每个模板/主题样式条件,模板/主题样式都会获得特定分数。在分析所有模板/主题样式后,Bricks 选择得分最高的那个。如果你需要使用筛选器 builder/settings/template/controls_data 或 bricks/theme_styles/controls 添加新的模板条件,那么你需要挂入评分逻辑以根据自定义条件对模板/主题样式进行评分。这就是 bricks/screen_conditions/scores 筛选器的用武之地,如下所示:示例 1:在作者归档模板中为特定作者角色添加分数在使用 builder/settings/template/controls_data 添加控件后(参见示例 1),我们现在需要挂入 bricks/screen_conditions/scores 以根据条件对模板进行评分,如下所示:"
  },
  "example_usage": null
}

前言

Bricks 根据你定义的条件为特定页面选择模板和主题样式。内部通过 0 到 10 的评分系统完成。0 是最不特定的,10 是最特定的(例如特定的文章 ID)。对于可以应用于特定上下文的每个模板/主题样式条件,模板/主题样式都会获得特定分数。在分析所有模板/主题样式后,Bricks 选择得分最高的那个。如果你需要使用筛选器 builder/settings/template/controls_data 或 bricks/theme_styles/controls 添加新的模板条件,那么你需要挂入评分逻辑以根据自定义条件对模板/主题样式进行评分。这就是 bricks/screen_conditions/scores 筛选器的用武之地,如下所示:示例 1:在作者归档模板中为特定作者角色添加分数在使用 builder/settings/template/controls_data 添加控件后(参见示例 1),我们现在需要挂入 bricks/screen_conditions/scores 以根据条件对模板进行评分,如下所示:

补充说明

更多细节可参考 官方文档