Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read item fields in Umbraco template Programmatically

Tags:

umbraco

Im trying to read a value programmatically in an umbraco template

So, instead of

<umbraco:Item runat="server" Field="url"></umbraco:Item>

Id like to write

<%=umbraco.item.Field %>

Or similar :)

I have searched most of the web now but found nothing. Any help is highly appreciated!

like image 746
Eric Herlitz Avatar asked Nov 18 '25 00:11

Eric Herlitz


1 Answers

The current page object isn't passed into the master page or .NET macros (before Umbraco 4.6.0, 4.6.0 does kind of support that).

The only way you can do what you're after would be with:

<%= umbraco.presentation.nodeFactory.Node.GetCurrent().GetProperty("Field").Value %>
like image 176
Aaron Powell Avatar answered Nov 21 '25 08:11

Aaron Powell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!