UmbracoHelper
Using the Umbraco Helper
How to reference UmbracoHelper
using System.Linq;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Web.Common;
using Umbraco.Cms.Web.Common.Controllers;
namespace UmbracoHelperDocs.Controllers;
[Route("customcontent/[action]")]
public class CustomContentController : Controller
{
private readonly UmbracoHelper _umbracoHelper;
public CustomContentController(UmbracoHelper umbracoHelper)
=> _umbracoHelper = umbracoHelper;
public IActionResult GetHomeNodeName()
{
IPublishedContent rootNode = _umbracoHelper
.ContentAtRoot()
.FirstOrDefault();
if (rootNode is null)
{
return NotFound();
}
return Ok(rootNode.Name);
}
}IPublishedContent
Working with Content
.Content(Guid id)
.ContentAtRoot()
.ContentAtXPath(string xpath)
.ContentSingleAtXPath(string xpath)
Working with Media
.Media(Guid id)
.MediaAtRoot()
Working with Tags
Working with Members
Searching
Fetching Dictionary Values
.GetDictionaryValue(string key)
Templating Helpers
.RenderMacro(string alias, object parameters)
.RenderTemplateAsync(int contentId, int? altTemplateId)
Last updated
Was this helpful?