Can't receive "Menu item CSS class" value

Vasyl Chepil asked on April 26, 2018 02:32

I'm tring to receive "Menu item CSS class" value I tried to do this with the next code but it does not return correct value

protected string GetMenuItemClass(TreeNode node)
{
     var menuItemClass = ValidationHelper.GetString(node.DocumentMenuClass, string.Empty);

     var inputText = currentResolver.ResolveMacros(menuItemClass);
     inputText = HTMLHelper.HTMLEncode(inputText);

     return inputText;
}

in case I change node.DocumentMenuClass to node.DocumentMenuRedirectUrl it returns corect "Inactive menu item redirect to URL" value

what I'm doing wrong?

Correct Answer

Peter Mogilnitski answered on April 26, 2018 04:38

Ahem .... set the menu class and check it

1 votesVote for this answer Unmark Correct answer

Recent Answers


Peter Mogilnitski answered on April 26, 2018 03:49 (last edited on April 26, 2018 03:58)

It should work if it is compiling i.e TreeNode comes from CMS.DocumentEngine namespace. You probably looking at the wrong document. Check node.DocumentCulture and node.DocumentName or node.DocumentID just to make sure that you looking at the right document.

I see that you are resolving macro so your node.DocumentMenuClass contains some macro {%somemacro%}. If somemacro fails - you get empty string.

1 votesVote for this answer Mark as a Correct answer

Vasyl Chepil answered on April 26, 2018 04:09

node.DocumentCulture and node.DocumentName or node.DocumentID they all work fine and return expected values


I'm planning to use macro in that field but currently I use simple text

0 votesVote for this answer Mark as a Correct answer

Vasyl Chepil answered on April 26, 2018 05:19 (last edited on April 26, 2018 05:19)

thanks Peter Mogilnitski

The mistake was located, I've forgot to load field data from db (

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.