Get CurrentPage in Partial View Macro Files Umbraco 11
Hi,
In my Umbraco 7.15.7 I'm getting the Current page in Partial View Macro Files as follow:
@{
if(CurrentPage.HasValue("articleImg")){
string w = (string)Umbraco.Media(CurrentPage.articleImg.ToString()).umbracoWidth;
string h = (string)Umbraco.Media(CurrentPage.articleImg.ToString()).umbracoHeight;
So in Umbraco 11 I tried as following:
@{
if(Model.HasValue("articleImg")){
string w = (string)Umbraco.Media(Model.articleImg.ToString()).umbracoWidth;
string h = (string)Umbraco.Media(Model.articleImg.ToString()).umbracoHeight;
(Model instead of CurrentPage)
But I'm getting this error:
'PartialViewMacroModel' does not contain a definition for 'HasValue' and the best extension method overload 'PublishedElementExtensions.HasValue(IPublishedElement, string, string?, string?)' requires a receiver of type 'IPublishedElement'
if(Model.HasValue("articleImg")){
Get CurrentPage in Partial View Macro Files Umbraco 11
Hi, In my Umbraco 7.15.7 I'm getting the Current page in Partial View Macro Files as follow:
So in Umbraco 11 I tried as following:
(Model instead of CurrentPage)
But I'm getting this error:
Any idea?
Thanks
Hi Meni,
You need to use
Model.Content.HasValue("articleImg")
Thanks. works.
is working on a reply...