Hi guys,
In my previous project I used code-first item types.
It took some try-and-error to get a working itementry class, mostly because I couldn't find proper samples.
I didn't get to use all properties which are available when you create an item type using the CMS.
I'm looking for sample code of code-first item types in the most comprehensive version, so I can take what I need.
For example a simple news item itemtype with these specs:
Models/ViewModels/NewsItem
Name: Nieuwsbericht
SystemName: NewsItem
Description: Dit genereert een nieuwsbericht
Item activated for: Pages
Icon: text_code_colored.png
Icon miniturized: TextCode.png
URL generation: true
Item cache: true
Category: Content
Title Field: Title
Type SystemName Group Label Required Options Default value
------------------------------------------------------------------------------------------------------------------------------------------------------------
Int NewsItemId MappingFields ID true Auto number
Select NewsCategoryId MappingFields Categorie true * from categories First category
(Multi)Select RegionId MappingFields Regio true * from regions "Niet regio specifiek"
String Title StandardFields Titel true
String SubTitle StandardFields Sub titel false
LongText Text StandardFields Tekst true
DateTime NewsDate StandardFields Nieuwsdatum false
(Fixed)Radio NewsType StandardFields Type true News;Featured;Add News
File Image StandardFields Afbeelding false
Link LandingPage StandardFields Link naar false
LongText Tags Tagging Tags false
I would have this class file:
namespace MyApplication.Models.ViewModels
{
// NAME
[Name("Nieuwsbericht")]
// SYSTEM NAME = CLASSNAME
// DESCRIPTION
// can not find a sample how to implement this
// ITEM ACTIVATED FOR
// can not find a sample how to implement this
// ICONS
// can not find a sample how to implement this
// URL GENERATION (true/false)
// can not find a sample how to implement this
// ITEM CACHE (true/false)
// can not find a sample how to implement this
// ITEM TYPE CATEGORY
[Category("Content")]
// FIELD USED FOR TITLE
// can not find a sample how to implement this
public class NewsItem : ItemEntry
{
// MAPPING FIELDS
// NEWS ITEM ID
[Group("MappingFields")]
[Name("ID")]
[Required]
public int NewsItemId { get; set; }
// NEWS CATEGORY ID
[Group("MappingFields")]
[Name("Categorie")]
[Required]
// can not find a sample how to make a select box with queryable content and a default or selected value
// REGION ID
[Group("MappingFields")]
[Name("Regio")]
[Required]
// can not find a sample how to make a multi select list with queryable content and a default selected value or selected value(s)
// STANDARD FIELDS
// TITLE
[Group("StandardFields")]
[Name("Titel")]
[Required]
public string Title { get; set; }
// SUB TITLE
[Group("StandardFields")]
[Name("Subtitel")]
public string SubTitle { get; set; }
// TEXT
[Group("StandardFields")]
[Name("Tekst")]
[Required]
[LongText]
public string Text { get; set; }
// NEWS DATE
[Group("StandardFields")]
[Name("Nieuwsdatum")]
public DateTime NewsDate { get; set; }
// TYPE
[Group("StandardFields")]
[Name("Ype")]
[Required]
// can not find a sample how to make a radio button list with static content and a default or selected value
// IMAGE
[Group("StandardFields")]
[Name("Afbeelding")]
[File]
public string Image { get; set; }
// LINK
[Group("StandardFields")]
[Name("Link naar landingpage")]
[Link]
public string LandingPage { get; set; }
// TAGGING FIELDS
// TAGS
[Group("Taggin")]
[Name("Tags")]
[LongText]
public string Tags { get; set; }
}
}