0

i been trying to get a node by a id with razor in a marco but can't get it to work with all the samples.

My code look like this

@using umbraco.MacroEngines
@inherits umbraco.MacroEngines.DynamicNodeContext

@{
    var temp = Parameter.myFolderId;
    @temp;
    var node = @Library.NodeById(temp);

}

I got the temp's value, but i can't get the node.

i also tried it like this

var node = @Model.NodeById(temp);

The only error Umbraco shows is

Error loading MacroEngine script (file: myfile.cshtml)

I'm kinda new to Umbraco, so i could be a rookie mistake

Cindy Meister
  • 25,071
  • 21
  • 34
  • 43
DaCh
  • 921
  • 1
  • 14
  • 48

2 Answers2

0

I'm thinking there shouldn't be a @ before Library.NodeById, since you're already inside a code block?

@{
    var temp = Parameter.myFolderId;
    var node = Library.NodeById(temp);
}
Jannik Anker
  • 3,320
  • 1
  • 13
  • 21
  • Hm. How about the new ContentService then? https://our.umbraco.org/documentation/reference/management/services/contentservice – Jannik Anker Jan 06 '16 at 15:59
0

Found the problem.

There was a problem with my indexes following this thread

Community
  • 1
  • 1
DaCh
  • 921
  • 1
  • 14
  • 48