Kentico Macro- Node Index

Pavan Josyula asked on January 29, 2015 03:56

I have specific requirement, based on the node order of pages I need to apply different color scheme to pages.

So I have defined my CSS classes in this way scheme-0,scheme-1, scheme-2. All good I was doing the CurrentDocument.NodeOrder-1 using macros to apply color scheme.

Yesterday I found an issue when user adds a new Page and deletes existing one its not resetting node order. Forexample I have 3 pages with Node Order 1,2,3 to begin with and user adds new Page, the order of the new page is 4. Now user deletes Node 3 then I am left with three nodes with this order 1,2,4.

This is breaking my color scheme CSS.

My question is there a way I can access Node Index through Macros.

I am using 8.1

Recent Answers

Brenden Kehren answered on January 29, 2015 04:12

No need for a macro.

To properly order your repeater results by the order in the content tree use NodeLevel, NodeOrder, NodeName in the order by property. Then I believe you can simply use `<%# (DataItemIndex + 1) %> in your transformation to get the results you're looking for. DataItem index is a zero based index which is why I added 1 to it.

0 votesVote for this answer Mark as a Correct answer

Pavan Josyula answered on January 29, 2015 04:35

I dont have any repeater web part on the page it is just content.

0 votesVote for this answer Mark as a Correct answer

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