简体   繁体   English

Umbraco 7个列表

[英]Umbraco 7 lists

I am new to Umbraco, and am trying to get to grips with its concepts, in particular how to create lists. 我是Umbraco的新手,正在尝试掌握Umbraco的概念,尤其是如何创建列表。 For example, you might want a news listing that appears on a page as a list of headlines with mouseover extra content, but you don't want to be able to click on an item and open a full page, it's just there as a list. 例如,您可能希望新闻列表以带有鼠标悬停额外内容的标题列表的形式显示在页面上,但是您不希望能够单击某项并打开整个页面,而是以列表的形式出现。

You could create a repeating grid of content on the page itself, but that could become unwieldy. 您可以在页面本身上创建重复的内容网格,但这可能变得难以处理。

It looks like (correct me if I am wrong) the Umbraco way is to create a parent page, and each news item to be a child page, which can be edited individually, and use a partial view to list them on the required page. 看起来(如果我错了,请纠正我),Umbraco的方法是创建一个父页面,每个新闻项都是一个子页面,可以单独进行编辑,并使用局部视图在所需页面上列出它们。

Is this the recommended approach? 这是推荐的方法吗? If so, two questions : 如果是这样,则有两个问题:

  1. How do I exclude these news 'phantom' pages from the main navigation - I understand I could set a true/false property on the page with alias umbracoNaviHide and tick this (which excludes it from 'visible' in the queries) 如何从主导航中排除这些新闻“幻像”页面-我知道我可以在页面上使用别名umbracoNaviHide设置true / false属性并将其选中(将其从查询的“可见”中排除)
  2. If so, how do I prevent direct access to the news page by its url (the umbracoNaviHide does not prevent the page opening) 如果是这样,我如何防止通过其URL直接访问新闻页面(umbracoNaviHide不会阻止该页面打开)

Presumably these news pages would show in the back end main view as they would be descendants of the home page? 大概这些新闻页面将作为后端的后代显示在后端主视图中?

Any advice welcome! 任何意见欢迎!

You can use a Content Repository to hold content objects that won't be pages in your application. 您可以使用Content Repository来保存内容对象,这些对象将不是应用程序中的页面。

Use following steps: 使用以下步骤:

Step 1: Create the root content repository document type 步骤1:创建根内容存储库文档类型

Go to your backend to the Settings section. 转到后端的Settings部分。 Under Document Types create a new type and give it the name Content Elements . 在“ Document Types创建一个新类型,并将其命名为“ Content Elements After creating this make sure to check the checkbox of Allow at root in order to add this element to your root in the Content section. 创建此内容后,请确保选中“ Allow at root ”复选框,以便将该元素添加到“ Content部分的根目录中。

Step 2: Add your newly created document type to the root of the content 步骤2:将新创建的文档类型添加到内容的根目录

Go to the Content section and choose to add a new item directly under content ( select the three dots next to Content ). 转到“ Content部分,然后选择直接在内容下方添加新项(选择“ Content旁边的三个点)。

Select your Content Elements item, give it a name and click save. 选择您的Content Elements项,为其命名,然后单击保存。

Step 3: Remove the checkbox allow at root 步骤3:移除根目录允许的复选框

You only want to add one Content Reposity item to your root where you will place all items like news, jobs, locations,... 您只想在您的根目录中添加一个Content Reposity项,即可在其中放置所有项,例如新闻,工作,位置,...

Go to the settings of the Content Elements document type and remove the checkbox of Allow at root . 转到“ Content Elements文档类型的设置,然后删除“ Allow at root ”复选框。

Step 4: Create a child repository for each type 步骤4:为每种类型创建一个子存储库

Using your example I will now create a News document type which will be a child item of the Content Elements repository. 现在,以您的示例为例,创建一个News文档类型,它将是Content Elements资源库的子项。

Go to the Document Types under Setting in your backend and choose to add a new document type. 转到后端中“ Setting下的“ Document Types ”,然后选择添加新的文档类型。 Give it a name News and choose save. 给它起一个News名称,然后选择保存。

In the settings of the Content Elements check the checkbox of the newly created News item to allow as a child. 在“ Content Elements的设置中,选中新创建的“ News项的复选框以允许其作为子项。

Step 5: Add the news list in your content 步骤5:在您的内容中添加新闻列表

In the content section choose to add a new item under the Content Elements using the three dots. 在内容部分中,选择使用三个点在Content Elements下添加一个新项目。

Select the News item, give it a name and choose save. 选择新闻项,为其命名并选择保存。

Step 6: Create a new document for the news item 步骤6:为新闻项创建一个新文档

One more item is a NewsItem which will hold the properties/information of the item. 还有一个项目是NewsItem ,它将保存该项目的属性/信息。

Using the same steps of 4 you can easly add this. 使用4的相同步骤,您可以轻松地添加它。 Be aware that now you have to go to the News item where you will add a check to the NewsItem checkbox to allow as a child. 要知道,现在你必须去News项,您将添加一个检查到NewsItem复选框允许作为一个孩子。

Also now define some properties of the newsitem. 现在还定义newsitem的一些属性。

Step 7: Add newsitems in the content 步骤7:在内容中添加newsitems

Using the same steps from 5 you can now add items in the news list. 使用5中的相同步骤,现在可以在新闻列表中添加项目。

Step 8: How to place a content element on to your page 步骤8:如何在页面上放置内容元素

If you have created a page you can add a property with a ContentPicker datatype which can be used to select a item from the Content Elements repository. 如果创建了页面,则可以添加具有ContentPicker数据类型的属性,该属性可用于从Content Elements存储库中选择一项。 Or using partial views you can create a list from the News to get all items. 或使用部分视图,您可以从News创建列表以获取所有项目。

Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM