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 Repositoryto 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
Settingssection. UnderDocument Typescreate a new type and give it the nameContent Elements. After creating this make sure to check the checkbox ofAllow at rootin order to add this element to your root in theContentsection.Step 2: Add your newly created document type to the root of the content
Go to the
Contentsection and choose to add a new item directly under content ( select the three dots next toContent).Select your
Content Elementsitem, give it a name and click save.Step 3: Remove the checkbox allow at root
You only want to add one
Content Reposityitem to your root where you will place all items like news, jobs, locations,...Go to the settings of the
Content Elementsdocument 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
Newsdocument type which will be a child item of theContent Elementsrepository.Go to the
Document TypesunderSettingin your backend and choose to add a new document type. Give it a nameNewsand choose save.In the settings of the
Content Elementscheck the checkbox of the newly createdNewsitem 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 Elementsusing 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
NewsItemwhich 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
Newsitem where you will add a check to theNewsItemcheckbox 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
ContentPickerdatatype which can be used to select a item from theContent Elementsrepository. Or using partial views you can create a list from theNewsto get all items.Hope this helps!