Reputation: 752
I have created a Web rendering and try to get a specific Item by its path.
Something like this :
Item item=Sitecore.Context.Database.GetItem("/sitecore/content/home");
Is it possible to get item using @Model.Sitecore() ?
Thanks
Upvotes: 2
Views: 10666
Reputation: 1435
I don't recommend it, but you can just get it in your view with @{ }
@{
var item = Sitecore.Context.Database.GetItem("/sitecore/content/home");
}
You should really move to a Sitecore controller rendering and do this work in the controller and return the Item as your model.
public class YourController : Controller
{
public ActionResult Stuff()
{
var item = Sitecore.Context.Database.GetItem("/sitecore/content/home");
return View(item);
}
}
Your view
@model Sitecore.Data.Items.Item
<div>
@Model.DisplayName
</div>
Upvotes: 2