You can't have both the @inherits and the @model statement in the partial view, if you keep with your
@inherits UmbracoViewPage<IHeaderProperties>
Then this is making 'Model' be assigned to the IHeaderProperties interface, which is why your PageTitle (which isn't on your HeaderProperties composition, can't be accessed via Model.PageTitle)... but all is not lost.
As you have inherited from UmbracoViewPage, that also gives you access to the current page, via Umbraco.AssignedContentItem
so you could have
var currentPage = Umbraco.AssignedContentItem;
var _title = currentPage.HasValue("title") ? currentPage.Value("title") : currentPage.Name;
or if your PageTitle is on a common composition on all your Document Types perhaps called 'CommonPageProperties' then you could cast to the generated interface to be like this:
var currentPage = Umbraco.AssignedContentItem as ICommonPageProperties;
var _title = currentPage!=null && !string.IsNullOrWhiteSpace(currentPage.Title) ? currentPage.Title : currentPage.Name;
Partial View failing to read Name
Hi , I have header Partial View to set page header image and title and I have called this inside master.cshtml
I'm trying to read Page Title if not entered assign Name and add to Header I received below error , how do I resolve this please ?
type of conditional expression cannot be determined because there is no implicit conversion between 'string' and 'method group'
@model IPublishedContent
Hi Pathini
You can't have both the @inherits and the @model statement in the partial view, if you keep with your
Then this is making 'Model' be assigned to the IHeaderProperties interface, which is why your PageTitle (which isn't on your HeaderProperties composition, can't be accessed via Model.PageTitle)... but all is not lost.
As you have inherited from UmbracoViewPage, that also gives you access to the current page, via
Umbraco.AssignedContentItem
so you could have
or if your PageTitle is on a common composition on all your Document Types perhaps called 'CommonPageProperties' then you could cast to the generated interface to be like this:
regards
Marc
is working on a reply...