I installed DXA example site successfuly and can edit existing Entities.
To move it further, I want to create my own Schema, Component, Page Template and display it in the DXA example site.
What I did are:
- Create a new Schema, named MyItem, with two plain text fields Name and Description;
- Create a new Component Template, exactly the same as Article Template, just renamed it to MyItem
Go to the DxaWebApp, add a new folder Models under Core folder, then add a new class
MyItem.cs
, like below:[SemanticEntity(Vocab = "http://schema.org", EntityName = "ShopItem", Prefix = "s", Public = true)] public class MyItem : EntityModel { [SemanticProperty("s:name")] public string Name { get; set; } [SemanticProperty("s:description")] public string Description { get; set; } }
Add a new file
MyItem.cshtml
in the folder Entity, with below code:@model Sdl.Web.Site.Areas.Core.Models.ShopItem @Model.Name @Model.Description
Add a new page
MyItemPage.cshtml
under Page folder. Content is exactly the same asGeneralPage.cshtml
Create the new Page in CMS, attach the MyItem Component to it;
After that update the Navigation and refresh setting then publish the Page. I can see the new Page name be displayed in the portal navigation, and it will load the MyItemPage.cshtml
view. But there is no content be displayed in the page. Any idea why?