I am new to Umbraco, and am trying to get to grips with its concepts, in particular how to create lists. 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.
Is this the recommended approach? If so, two questions :
- 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)
- If so, how do I prevent direct access to the news page by its url (the umbracoNaviHide does not prevent the page opening)
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.Use following steps:
Step 1: Create the root content repository document type
Go to your backend to the
Settings
section. UnderDocument Types
create a new type and give it the nameContent Elements
. After creating this make sure to check the checkbox ofAllow at root
in order to add this element to your root in theContent
section.Step 2: Add your newly created document type to the root of the content
Go to the
Content
section and choose to add a new item directly under content ( select the three dots next toContent
).Select your
Content Elements
item, give it a name and click save.Step 3: Remove the checkbox allow at root
You only want to add one
Content Reposity
item to your root where you will place all items like news, jobs, locations,...Go to the settings of the
Content Elements
document type and remove the checkbox ofAllow at root
.Step 4: Create a child repository for each type
Using your example I will now create a
News
document type which will be a child item of theContent Elements
repository.Go to the
Document Types
underSetting
in your backend and choose to add a new document type. Give it a nameNews
and choose save.In the settings of the
Content Elements
check the checkbox of the newly createdNews
item to allow as a child.Step 5: Add the news list in your content
In the content section choose to add a new item under the
Content Elements
using the three dots.Select the News item, give it a name and choose save.
Step 6: Create a new document for the news item
One more item is a
NewsItem
which will hold the properties/information of the item.Using the same steps of 4 you can easly add this. Be aware that now you have to go to the
News
item where you will add a check to theNewsItem
checkbox to allow as a child.Also now define some properties of the newsitem.
Step 7: Add newsitems in the content
Using the same steps from 5 you can now add items in the news list.
Step 8: How to place a content element on to your page
If you have created a page you can add a property with a
ContentPicker
datatype which can be used to select a item from theContent Elements
repository. Or using partial views you can create a list from theNews
to get all items.Hope this helps!