In V6 Mvc it is @CurrentPage.Id (or Model equivalent), but it very much now depends upon the version of Umbraco you are using. It will also depend on what you want to do with the node, once you have it as to the best way forward.
Even though dated the link below is a very good source to point you in the direction to achieving the call you need. (I believe it was created for 4.7, but is still very useable, even if not 100% in every detail)
If you want to get a node anywhere inside Umbraco (here the property "Name" in node 1105), you can use @Model.NodeById(1105).Name. Hope that this helps you :-)
@Richard, I'd suggest against hardcoding IDs in the config, for example IDs may change then deploying a site via Courier - such nodes would likely have unique document types so easy to find via the API (the above uses XPath internally so nice and quick).
Get node by type alias in API
How do you find the id of a node type by its alias using the API without jquery?
Can it be accessed directly like in razor e.g Model.AncestorOrSelf().Descendants("MyTypeAlias").First() ?
Thanks
Hi Pete
In V6 Mvc it is @CurrentPage.Id (or Model equivalent), but it very much now depends upon the version of Umbraco you are using. It will also depend on what you want to do with the node, once you have it as to the best way forward.
Even though dated the link below is a very good source to point you in the direction to achieving the call you need. (I believe it was created for 4.7, but is still very useable, even if not 100% in every detail)
http://our.umbraco.org/projects/developer-tools/razor-dynamicnode-cheat-sheet
Hope it helps
G
Hi Pete
If you want to get a node anywhere inside Umbraco (here the property "Name" in node 1105), you can use @Model.NodeById(1105).Name. Hope that this helps you :-)
Lars
Thanks richard.
So you have to use .Where in the api, shame there isn't a direct handler.
Pete
or how about:
@Richard, I'd suggest against hardcoding IDs in the config, for example IDs may change then deploying a site via Courier - such nodes would likely have unique document types so easy to find via the API (the above uses XPath internally so nice and quick).
I support Hendy's answer because this ist the fastest why and even cached.
is working on a reply...