I am a young tridion developer with not much experience. I am using Tridion 2013sp1 and creating a new MVC web application in C#.
I would like to create a menu in which each element could be a 'submenu' for generic menus, so it will let me implement generic multiple level menus.
I have created an schema like this for the root of the menu:
HeaderMenuDesplegable:
title:Text
item:ComponentLink<HeaderMenuDesplegableItem> (multiples values)
And this one for the childrens:
HeaderMenuDesplegableItem:
title:Text
link:Link
subItem:ComponentLink<HeaderMenuDesplegableItem> (multiples values)
So it has a field which is a component link to an element with the same schema.
I have create several components for creating an example menu like this:
MainMenu-> {title:'menu',items:Submenu1}
Submenu1-> [
{title:'e1', link:{linkTex:'l1',URL:'#'}, items: null},
{title:'e2', link:{linkTex:'le2',URL:'#'}, items: Submenu2}
]
Submenu2-> [
{title:'e21', link:{linkTex:'l21',URL:'#'}, items: Submenu3}
]
Submenu3->[
{title:'e211', link:{linkTex:'l211',URL:'#'}, items: null},
{title:'e212', link:{linkTex:'l212',URL:'#'}, items: null},
]So i will have a menu like:
Menu
|-e1
|-e2
|e21
|e211
|e211
Well for mapping this in my c# mvc application, i have created the properlies models.
public class HeaderMenuDesplegable : EntityModel
{
public string Title { get; set; }
//it's Items with 's' for making the properly mapping from tridion multiple values
public List<HeaderMenuDesplegableItem> Items { get; set; }
}
public class HeaderMenuDesplegableItem : EntityModel
{
public string Title { get; set; }
public Link Link { get; set; }
//it's SubItems with 's' for making the properly mapping from tridion multiple values
public List<HeaderMenuDesplegableItem> SubItems { get; set; }
}
When I am debuging, I got the content for the father (menu), its list of items (first level), e1 and e2, I get that e2 has a list of subitems with count = 1, BUT THE PROBLEM, is the element has all its fields to null!
I don't know if the problem is in the mapping or if this kind of structure is not allowed. My surprise is that it recognizes the sublist of children for e2, with one element, but that element has all fields to null. So it seems that everything is working fine but I am missing something.