# 主题和相关主题组件报告

**URL:** https://meta.discourse.org/t/themes-and-associated-theme-components-report/386372
**Category:** Data & reporting
**Tags:** sql-query
**Created:** [2025年十月21日 21:17 UTC](https://meta.discourse.org/t/themes-and-associated-theme-components-report/386372 "2025-10-21T21:17:32Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![SaraDev](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/saradev/32/335139_2.png) [@SaraDev](https://meta.discourse.org/u/SaraDev)
#### Post date: [2025年十月21日 21:17 UTC](https://meta.discourse.org/t/themes-and-associated-theme-components-report/386372/1 "2025-10-21T21:17:32Z")

</div>

此查询可全面了解 Discourse 实例中的所有主题及其已安装的组件，对于管理多个主题并需要快速识别每个主题上安装了哪些组件的管理员来说非常有用。

```sql
-- [params]
-- null text :theme_name

-- 查询以列出所有主题及其关联的已安装组件
WITH parent_themes AS (
  SELECT id, name
  FROM themes
  WHERE component = false
    AND (:theme_name IS NULL OR name ILIKE '%' || :theme_name || '%')
)

SELECT
  pt.name AS theme_name,
  ct.name AS component_name,
  ct.enabled AS component_enabled
FROM parent_themes pt
LEFT JOIN child_themes child ON child.parent_theme_id = pt.id
LEFT JOIN themes ct ON ct.id = child.child_theme_id
ORDER BY pt.name, ct.name

```

### 参数

- **theme\_name** ：（可选）过滤结果，仅显示包含此文本的主题。默认视图显示所有主题及其组件。

### 结果

- **theme\_name** ：每个主题的名称。
- **component\_name** ：安装在主题上的组件的名称。
- **component\_enabled** ：组件是否已启用（true）或禁用（false）。

没有组件的主题将显示为 component 字段的 NULL 值。结果按主题名称和组件名称的字母顺序排序。

### 示例结果

| theme\_name | component\_name | component\_enabled |
| --- | --- | --- |
| Default | discourse-adplugin | true |
| Default | discourse-chat | true |
| Default | discourse-signatures | false |
| Corporate | discourse-header-search | true |
| Corporate | discourse-tooltips | true |
