Getting custom fields in hierarchical viewer menu transformation

Well Studio Admin asked on April 14, 2014 09:38

Hello,

I'm trying to create a mega-nav in Kentico 7. I've managed to use a hierarchical viewer to do it, but now I want to add custom text and other info to each drop-down of the mega-nav.

See this mega-nav for an example (but imagine more text panes and images) - http://www.royalmail.com/

To do this I've decided that the best course of action would be to have some custom fields that I can input on the menu item form. I don't want to create completely new menu items just to add a text box and an image.

I've added a new field using Administration > Development > Document Types > Page (menu item) > Fields. I'm finding it impossible to access this data in the hierarchical viewer transformation. The transformation is under cms.menuitem. The transformation on hierarchical view is for just cms.menuitem and is level 0, it is not ascx, but a text/xml macro.

Is there anyone that can provide me with some code that will grab that data from the current document? I've tried -

{% cmscontext.CurrentAliasPath.MeganavDescription #%}

{% cmscontext.CurrentDocument.MeganavDescription #%}

{% Documents[NodeAliasPath].MeganavDescription #%}

{% MeganavDescription %}

{% CurrentDocument.MeganavDescription #%}

{% GetValue('MeganavDescription') %}

{% CurrentDocument.GetValue('MeganavDescription') %} and many more.

None of these work. Is there any way to get a macro to output this custom data? I've been bashing my head against the wall trying to find a solution, but I can't see anything in the documentation that seems to help.

This is the last bit of information that I need to know before I can fully achieve my aims with Kentico. Any help would be massively appreciated!

Thanks!

Recent Answers


Brenden Kehren answered on April 14, 2014 10:16 (last edited on December 10, 2019 02:30)

To get the current document being rendered in your listing webpart you'd use {% MeganavDescription %}. If you want to get the document you are navigating to, you'd need to use {% CurrentDocument.GetValue("MeganavDescription") |(identity)GlobalAdministrator%}

Have you tried turning on debugging to see what is being rendered or looked in Event log to see if any events are being generated

0 votesVote for this answer Mark as a Correct answer

Well Studio Admin answered on April 14, 2014 11:30

Neither one of these are working unfortunately. I want to assign a custom field to each menu item (by adding one on the form field for each). When you hover over each title I would like to use that custom field data. It just doesn't seem to be pulling across, whichever method I try.

Debug doesn't seem to provide much help.

0 votesVote for this answer Mark as a Correct answer

Well Studio Admin answered on April 14, 2014 11:38

Well, actually {% MeganavDescription %} does work, but for the currently viewed document(picture 6 sets of text on each meganav panel saying the same thing. What I need is to get one for the individual documents. I just can't seem to find it anywhere.... The debug does give some handy additional info, but I don't think it's enough...

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on April 15, 2014 06:57 (last edited on December 10, 2019 02:30)

Are you sure you have your hierarchy setup right with your transformations? {% MeganavDescription %} should display the document being rendered data. For instance if you have:

-Home
--Products
---Prod1
---Prod2
---Prod3

If you were navigating to /Products/Prod2, it should render Prod1 description, Prod2 description, Prod3 description as each of the documents are being rendered in the navigation. If you simply want the current document you are navigating to, you'd use {% CurrentDocument.GetValue("MeganavDescription") |(identity)GlobalAdministrator%}. Then you'd see Prod2 description, Prod2 description, Prod2 description.

If you were using ASCX transformation it would be the difference between <%# Eval("MeganavDescription") %> and <%# CurrentDocument.GetValue("MeganavDescription") %>

0 votesVote for this answer Mark as a Correct answer

Jan Hermann answered on May 1, 2014 00:53 (last edited on December 10, 2019 02:30)

Please use following macro instead: {%Documents.WithAllData[NodeAliasPath].GetValue("custom_field")|(identity)GlobalAdministrator%}

0 votesVote for this answer Mark as a Correct answer

Well Studio Admin answered on May 2, 2014 05:58

I can confirm that this worked for me!

0 votesVote for this answer Mark as a Correct answer

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