Skip to content

In Orchard, a widget is a fragment of UI (such as HTML) and code (such as a content part) that can be easily mapped to any location or zone in the active theme, such as a sidebar or footer zone. Examples of widgets include navigation menus, image galleries, ads, videos, and tag clouds.

在Orchard中,窗口小部件是UI(例如HTML)和代码(例如内容部分)的片段,可以轻松映射到活动主题中的任何位置或区域,例如侧边栏或页脚区域。小部件的示例包括导航菜单,图像库,广告,视频和标签云。

This article explains the basics of widgets and shows you how to manage them.

本文介绍了小部件的基础知识,并向您展示了如何管理它们。

Layers, Zones, and Widgets

图层,区域和小部件

In Orchard, you manage widgets by clicking Widgets in the dashboard. The Widgets screen lists the available widgets and lets you assign the widget to a layer and a zone.

在Orchard中,您可以通过单击仪表板中的小部件来管理小部件。 Widgets 屏幕列出了可用的小部件,并允许您将小部件分配给_layer_和_zone_。

You can think of a layer as a set of rules for displaying a widget (or group of widgets). For example, a layer might display a widget on a specific page only if the user is logged in. A zone helps to position a widget on a page.

您可以将_layer_视为一组用于显示窗口小部件(或窗口小部件组)的规则。例如,仅当用户登录时,图层才可能在特定页面上显示窗口小部件._zone_有助于在窗口上放置窗口小部件。

The following image shows the Widgets screen.

下图显示了 Widgets 屏幕。

Available Widgets

可用的小部件

Whenever a widget becomes available (usually by enabling another feature in the Features tab on the Modules screen of the dashboard), Orchard adds it to the list of available widgets that can be added to zones in the current theme. To see the list of widgets available in a zone, in the Widgets screen, click the Add button on one of the listed zones.

每当一个小部件可用时(通常通过在仪表板的 Modules 屏幕上的 Features 选项卡中启用另一个功能),Orchard会将其添加到可添加到当前区域的可用小部件列表中主题。要查看区域中可用的窗口小部件列表,请在窗口小部件屏幕中,单击其中一个列出的区域上的添加按钮。

For example, in the Widgets screen click Add for the Header zone. A screen is displayed that allows you to choose one of the available widgets.

例如,在 Widgets 屏幕中,单击 Add 作为 Header 区域。将显示一个屏幕,允许您选择一个可用的小组件。

The following table describes the widgets that are available by default in Orchard:

下表描述了Orchard中默认可用的小部件:

Widget | Description

小工具|描述

--------------------- | ------------------------------------------------------------------

  • | -------------------------------------------------- ----------------

Blog Archives | Displays a list of archived entries for the specified blog.

博客档案 |显示指定博客的已归档条目列表。

Container Widget | Displays a "contained" content item, such as a list.

容器小工具 |显示“包含”的内容项,例如列表。

Html Widget | Displays HTML content, which is entered using the widget's editor.

Html Widget |显示使用窗口小部件编辑器输入的HTML内容。

Recent Blog Posts | Displays a list of recent posts for the specified blog.

最近的博客文章 |显示指定博客的最新帖子列表。

List of Layers

图层列表

Orchard comes with a number of layers already defined. You can define additional layers as needed, as discussed later in Adding a Layer. In the Widgets screen, you can edit the existing layers by selecting a layer in the Current Layer drop-down list, or you can add new layers by clicking Add a new layer.

Orchard附带了许多已定义的图层。您可以根据需要定义其他图层,稍后将在[添加图层](Managing-widgets#AddingaLayer)中进行讨论。在 Widgets 屏幕中,您可以通过在 Current Layer 下拉列表中选择一个图层来编辑现有图层,也可以通过单击 Add a new layer 来添加新图层。

The following table lists the default layers, shows the rule that defines the layer, and describes the effect of the layer.

下表列出了默认图层,显示了定义图层的规则,并描述了图层的效果。

Layer | Rule | Description

图层|规则|描述

-------------- | ----------------- | ---------------------------------------

  • | ----------------- | ---------------------------------------

Default | true | Always displayed on every page.

默认|是的|始终显示在每个页面上。

Authenticated | authenticated | Displayed if the user is authenticated.

认证|经过验证的如果用户已通过身份验证,则显示。

Anonymous | not authenticated | Displayed if the user is anonymous.

匿名|未经过身份验证|如果用户是匿名的,则显示。

Disabled | false | Not displayed. This layer is provided as way to save the configuration of widgets that are not currently displayed.

禁用|假|没有显示。提供此层是为了保存当前未显示的窗口小部件的配置。

TheHomepage | url("~/") | Displayed on the home page.

主页| url(“〜/”)|显示在主页上。

List of Zones

区域列表

In Orchard, a web page is divided into zones (regions). The available zones are defined by the website's theme. In the Widgets screen, you can see the list of all zones available for the currently selected layer. The list also shows the widgets assigned to each zone for the selected layer.

在Orchard中,网页被划分为区域(区域)。可用区域由网站主题定义。在窗口小部件屏幕中,您可以看到当前所选图层的所有可用区域列表。该列表还显示为所选图层分配给每个区域的小组件。

For information about the zones that are available in the default theme (TheThemeMachine), see Customizing the Default Theme.

有关默认主题(TheThemeMachine)中可用区域的信息,请参阅[自定义默认主题](自定义默认主题)。

Adding a Layer

添加图层

To add a layer, in the dashboard, click Widgets. On the Widgets screen, click Add a new layer. The Add Layer screen is displayed:

要添加图层,请在仪表板中单击 Widgets 。在 Widgets 屏幕上,单击添加新图层。将显示添加图层屏幕:

To define the new layer, enter the name of the layer, a description, and the rule that defines the layer. When you're finished, click Save.

要定义新图层,请输入图层的名称,描述以及定义图层的规则。完成后,单击保存

The Layer Rule value is an expression that resolves to either true or false. If it resolves to true, the widget is displayed; otherwise the widget is not displayed. For all the available rules, and their syntax see Using Rules to conditionally display content

Layer Rule 值是一个解析为 true false 的表达式。如果它解析为 true ,则显示小部件;否则不显示小部件。对于所有可用规则及其语法,请参阅[使用规则有条件地显示内容](使用规则 - 有条件地显示内容)

Assigning a Widget to a Zone

将小组件分配给区域

To assign a widget to a zone, click the Add button on a zone that you want to add the widget to, and then select the widget to add.

要将窗口小部件分配给区域,请单击要添加窗口小部件的区域上的添加按钮,然后选择要添加的窗口小部件。

For example, click Add on the Header zone, and then in the Choose A Widget screen click the Html Widget.

例如,单击标题区域上的添加,然后在选择一个小组件屏幕中单击 Html小组件

The Add A Widget screen is displayed.

将显示添加小组件屏幕。

The fields you need to fill in depend on the widget you're configuring. However, all widgets have Zone, Layer, Title, and Position fields. The Position field determines the relative position of all widgets within the zone (in effect, z-order). Keep in mind that the widgets within the zone can come from multiple layers. For example, two different layers might have widgets assigned to the same zone.

您需要填写的字段取决于您正在配置的小部件。但是,所有小部件都有 Zone Layer Title Position 字段。 Position 字段确定区域内所有小部件的相对位置(实际上是z顺序)。请记住,区域中的小部件可以来自多个层。例如,两个不同的层可能具有分配给同一区域的小部件。

The value of the Position field can be an integer or a sequence of integers separated by dots. For example, the following values are all valid: 5, 10.1, 7.5.3.1. Widgets with lower position values will be rendered before those with higher values.

Position 字段的值可以是整数或由点分隔的整数序列。例如,以下值均有效:5,10.1,7.5.3.1。具有较低位置值的窗口小部件将在具有较高值的​​窗口小部件之前呈现。

After setting the values of all fields, click Save.

设置所有字段的值后,单击保存

Editing or Deleting a Widget

编辑或删除小组件

To edit or delete a widget, in the Widgets screen, use the Current Layer drop-down list to select the layer that the widget is assigned to. In the list of zones displayed for the layer, click the widget you want to edit. The Edit Widget screen is displayed:

要编辑或删除窗口小部件,请在窗口小部件屏幕中,使用当前图层下拉列表选择窗口小部件所分配的图层。在为图层显示的区域列表中,单击要编辑的小组件。将显示 Edit Widget 屏幕:

Edit the field you want to change, then click Save. To remove the widget from the zone, click Delete.

编辑要更改的字段,然后单击保存。要从区域中删除小部件,请单击删除

Change History

改变历史

  • Updates for Orchard 1.1

  • Orchard 1.1的更新 *

    • 3-16-11: Updated screen shots for 1.1 version.
  • Updates for Orchard 1.7

  • Orchard 1.7的更新 *

    • 4-4-14: Added Content Type rule