U4-7608 - Ancestor page field displaying instead of current page field

Created by Ben 23 Dec 2015, 16:03:03 Updated by Ben 19 Aug 2016, 14:41:31

Duplicates: U4-8617

What did you do?

I created a page field called alternatePageTitle as a Textstring type. I then used the following on a template:

What did you expect to happen? I expected the current page name or the alternatePageTitle for the current page to be displayed.

What actually happened? The alternatePageTitle field was left blank and Umbraco pulled in the alternatePageTitle from an ancestor page. Specifically it used the Grandfather page of the current page because it was the first ancestor in the tree that had a value in the alternatePageTitle field.

The same thing was happening with a Richtext Editor field.

I have also documented it here with a temporary solution I am using: https://our.umbraco.org/forum/umbraco-7/using-umbraco-7/73905-ancestor-field-displaying-instead-of-current-page-field-umbraco-v734

Comments

Ben 15 Jun 2016, 19:55:08

Just checked this on 7.4.3 and am still experiencing this issue.


Jannes Meyer 19 Aug 2016, 13:37:09

Sorry, I think I created a duplicate for this bug.

Maybe it's also worth noting that in my case it is an Umbraco install that started out on v4 and was upgraded several times.


Ben 19 Aug 2016, 13:44:46

In my case I started with v7 and have upgraded it to 7.4.3. I have tried this with fresh versions and still find this to be a problem for me.


Jannes Meyer 19 Aug 2016, 14:19:56

Looks like Razor is the solution to our problem: http://issues.umbraco.org/issue/U4-8617#comment=67-29768

<umbraco:Macro runat="server" language="cshtml"> @if(!string.IsNullOrEmpty(Model.alternatePageTitle)) { @Model.alternatePageTitle } else { @Model.pageName } </umbraco:Macro>


Ben 19 Aug 2016, 14:29:44

Thanks for posting Jannes. The solution I am currently using is a partial view that looks like this:

@{ var pageField = Model.MacroParameters["pageField"].ToString(); var insertBeforeString = HttpUtility.HtmlDecode(Model.MacroParameters["insertBefore"].ToString()); var insertAfterString = HttpUtility.HtmlDecode(Model.MacroParameters["insertAfter"].ToString()); var altPageField = Model.MacroParameters["altPageField"].ToString();

@Umbraco.Field(pageField, altFieldAlias: altPageField, insertBefore: insertBeforeString, insertAfter: insertAfterString)

}


Priority: Normal

Type: Bug

State: Duplicate

Assignee:

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted:

Affected versions: 7.5.0, 7.3.4, 7.4.1, 7.3.5, 7.3.6, 7.3.7, 7.3.8, 7.4.2, 7.4.3

Due in version:

Sprint:

Story Points:

Cycle: