Developer Reference — Helpers & Extensions
Razor helpers, current site context, media, CSS architecture
Developer Reference β Helpers & Extensions
uTPro ships a set of Razor/C# helpers used throughout the views. Add @using uTPro.Extension; where needed.
Current Site & Item Context
ICurrentSiteExtension (injected as CurrentSite) gives per-request site context:
CurrentSite.GetItem()β key nodes (Root, FolderSettings, PageHome, Current, PageErrors)CurrentCulture/DefaultCultureβ active and default culturesGetCultures()β all published culturesGetDictionaryValue(key)β dictionary translation lookup
Content Inheritance
ContentExtensions resolves values inherited down the tree (self β ancestors) with per-request caching. Used for topComponent/bottomComponent cascading.
Media & Responsive Images
ResponsiveImg(...) renders responsive img (WebP + srcset). Key params: alt, cssClass, sizes, priority (LCP), quality (default 80).
ValueToMediaDesktop/Tablet/Mobile returns resized media URL strings (2048/1500/800).
HTML & String Helpers
| Helper | Purpose |
|---|---|
ToHtml() | Renders CMS HTML with best-effort sanitization |
ToInline() | Collapses newlines to spaces |
LinkToString() | Safe URL from Umbraco Link |
CSS Architecture
Convention-based CSS in wwwroot/css/{SiteName}/:
- variables.css β Design tokens (all colors)
- critical.css β Inlined in head
- layout.css β Reset + grid + typography
- main.css β Components + responsive
- Components/ β Per-component CSS files
Each component has a matching CSS file registered via SetSection. CSS is only loaded when the component appears on a page.
Block Preview Aware Components
Components detect preview mode via Context.Request.IsBlockPreviewRequest() and render CSS only (no JS) in preview.