4

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.

  • Welcome to the Tridion Stack Exchange site! I've made some edits to your question for grammar and formatting. If you disagree with any of my changes please feel free to revert them. Additionally I would suggest modifying your question title to make it clearer what your question is to better attract interest from the community. – Glenn Stevens Oct 6 '15 at 0:28
1

Not sure why the value is not populating, but another way this can be achieved is by defining the metadata field in both schema for column and level. For e.g., in Schema HeaderMenuDesplegable have 1 or 2 or 3 .... column defined by content user & in schema HeaderMenuDesplegableItem have 1.1 or 1.1.1 or 2.1 or 2.1.1 level and column number .... defined by content user.

HeaderMenuDesplegable: title:Text item:ComponentLink (multiples values) Metadata : Text

HeaderMenuDesplegableItem: title:Text link:Link Metadata : Text

Easy to fetch Matadata field and handle the functionality with C# logic.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.