高级搜索横幅

:warning:

此主题组件已弃用,不再建议使用。其功能现已集成到 Discourse Core 中 —— 请参阅我们的文档,了解如何设置欢迎横幅:

Creating a banner to display at the top of your site

:discourse2: 摘要 高级搜索横幅 在主话题列表导航上方放置一个搜索栏,并可选地包含标题和副标题文本。
:eyeglasses: 预览 在 Discourse Theme Creator 上预览
:hammer_and_wrench: 仓库链接 https://github.com/discourse/discourse-search-banner
:open_book: 初次使用 Discourse 主题? Discourse 主题使用初学者指南

安装此主题组件

功能

默认情况下,此横幅出现在所有顶级话题页面上(最新/新/未读/热门/分类……即 顶部菜单 站点设置中的任何内容),但也可以设置为仅在社区的首页显示。

设置

名称 描述
显示位置 决定横幅出现在哪些页面上
插件出口 横幅在页面上的显示位置
浅色背景图片 浅色配色方案下横幅的背景图片
深色背景图片 深色配色方案下横幅的背景图片
平铺背景图片 重复背景图片
显示给谁 谁可以看到搜索横幅(已登录、未登录或两者皆可)
特殊样式 可选的变体,用于更改搜索横幅的外观
翻译 默认值
search_banner.headline 欢迎来到我们的社区
search_banner.subhead 很高兴您来到这里。如果需要帮助,请在发帖前进行搜索。
search_banner.search_button_text

若要省略某一项不显示,请将字段留空。

自定义样式

HTML 元素在此横幅出现的任何位置都会获得名为 .display-search-banner 的类,而横幅本身被包裹在 .custom-search-banner 类中,因此通过一些 CSS,您应该能够根据需要自定义此横幅的外观。

未来增强

  • 添加选项以在特定分类中启用横幅

致谢

:sparkling_heart: 此组件大量借鉴了 @angusPavilion Header Search Theme Component


:discourse2: 由我们托管? 主题组件在我们的 Standard、Business 和 Enterprise 计划中均可使用。

83 个赞
[PAID] New search bar
Bringing popular features to Discourse: Header search, welcome banner, and category icons / emoji
Elementary Layout Component
Searching for users on mobile
New Theme: Tag-Pages Navigation
How to add links on home page menu to other site?
New Theme: Tag-Pages Navigation
Adding Search option
Header search in custom header
Can't find how to localize a theme component
Creating and installing plugins?
Bug with "search_banner.search_button_text" shown in search banner theme component
Pavilion Header Search Theme Component
Help Needed for Installing Meta Branded Theme
Banner Featured Links
Search section like on Reddit?
How do I edit "Welcome to our community" and tagline on the Homepage?
Anything wrong with this component?
User card out of alignment
Search Banner image cuts off on smaller screens
Pavilion Header Search Theme Component
Where to find search bar in our settings?
Where to find search bar in our settings?
3.5.0.beta9: Improving color management, core welcome banner, and staff action log filters
Welcome Banner components
What plug-in or customization for this header?
Translations of theme component sample texts
Homepage header, how to add?
How can I make the home page similar to this one?
Theme or Custom CSS on Monday’s Discourse Instance?
Community not displaying correctly - new problem - help!
Christmas Decoration Component :christmas_tree:
Challenge with non-admin users not getting page to load?
We're upgrading our icons to Font Awesome 6!
Search for and/or filter topics in a category using text search
Forum search bar not showing up
How to add custom links below welcome banner?
Pavilion Header Search Theme Component
Search banner requires login
Mint Theme
Advanced Header Search
Custom Platform
Making my discourse site look a certain way
How can I change the HTML template of advanced search?
Fully Theme
How to change the header text on the title page
How to make a custom search bar?
Bug in Search banner theme component
Simple modifications
How can I achieve these header and footer customisations?
Meta Branded theme and all categories header
Search in this topic filter issue with Search banner TC
Bug with "search_banner.search_button_text" shown in search banner theme component

我已更新主题组件以添加一些新设置:

show on — 此选项决定横幅显示的位置,可选值包括:

  • top_menu(最新/分类/热门/新消息/未读)
  • homepage
  • all(除默认搜索页面和管理页面外的所有页面)

show for — 此选项决定谁可以看到横幅:

  • everyone
  • logged_in
  • logged_out
17 个赞

我刚刚做了一个小更新,为该组件添加了一个可选样式,它提供了一个没有标题的大型搜索栏:

可以通过新的“特殊样式”设置启用此功能。这只会启用一些额外的 CSS。


我将来也可能会在此处添加更多选项!

8 个赞

如何更改此附加组件中“欢迎”文本的颜色?

1 个赞

没有该设置。但是,您可以使用一些 CSS 添加它:

将以下内容添加到您的主题或新的主题组件中,并根据需要进行更改。 :+1:

.search-banner > .custom-search-banner  {
    /* title */
    h1 {
        color: #286989;
    }
    
    /* description */
    p {
        color: #286989
    }
}
3 个赞

非常感谢!

2 个赞

是否有办法隐藏搜索图标(使用 CSS 或其他方式)?我遇到了一个问题,即在与此组件结合使用时,搜索图标会出现重复:Advanced Header Search - #56 by RBoy

1 个赞
.search-input .search-icon:first-child {
  display: none;
}

应该只显示一个搜索图标。不过,我要说的是,同时使用搜索横幅和标题搜索会带来一些糟糕的用户体验副作用。

我建议只使用其中一个。

4 个赞

谢谢!非常有帮助

您能详细说明一下,是什么用户体验副作用吗?

1 个赞

上面链接的视频展示了一些问题 :slight_smile:

  • 重叠的搜索下拉菜单
  • 搜索下拉菜单奇怪的打开和关闭状态
  • 在一个搜索输入框中,搜索图标是高级搜索的链接,而在另一个搜索输入框中则不是
  • 等等
2 个赞

好的。只要它们不在同一页面上,应该就没问题。

2 个赞

有人能帮帮我吗?我在 Discourse 上安装了这个主题,但图片右侧被裁剪了一部分,要让图片完全显示,我必须将站点的字体设置为“较小”。我有两个不同的 Discourse 安装,其中一个图片正常显示,另一个图片为什么被裁剪了?

2 个赞

可以包含截图吗?这将使问题更容易理解。

2 个赞

我在不同的浏览器/模式下显示图像的不同部分遇到了同样的问题。我通过将其做得非常宽来解决这个问题,这样右侧只在某些情况下显示。但对于对称图像来说,这并不容易。我猜想一些 CSS(无需搜索 thome-component-overwrite)会有帮助。

我设法解决了一部分问题,我禁用了其他主题中的主题组件,只保留了一个,令人难以置信的是,图像的字体大小为“正常”,只是因为手机的图像只显示了一侧,有什么办法可以让它在我的手机上完全显示吗?

您好,

有没有办法删除搜索横幅和标题之间的间距?

1 个赞

您可以使用此 CSS 在新的主题组件中:

.custom-search-banner-wrap {
    margin-top: 0;
}
3 个赞

完美运行,谢谢!

2 个赞

3 个帖子被拆分为新主题:“Can I add line breaks to Search Banner subheader text?

Discourse 似乎也有我社区遇到的同样问题,覆盖层需要一些时间才能覆盖搜索底层(Discover)下的内容:
2024-07-05 14.42.23

在我社区这个问题更明显:
2024-07-05 14.49.53

不知道有没有人遇到过解决方法,可能需要延迟显示覆盖层?这可能会导致糟糕的用户体验。

1 个赞