The issue to me is that part <div style="background:@parent.("eventsListingGradient");" class="bannerContent">
This background:@parent.("eventsListingGradient") is supposed to give me rgb code to change the background color but instead I have that in the html : background:Umbraco.Web.PublishedModels.EvenementsListing.(" eventslistinggradient")
What i want is in the doc type of page 1, the user enter rgb code and it renders on the page. To avoid the user to enter the rbg code many times, I want page 2 to get the value on page 1.
try either @parent.Value<string>("eventsListingGradient") or the same as you have done for the image src Model.Value<string>("eventsListingGradient", fallback: Fallback.ToAncestors)
Get ancestor field value
Hello guys !
I'm trying to get a filed from a parent with the ancestor method but it's not working.
My tree is like :
Master > Page 1 > Page 2
I want my page 2 to get a textbox value from the page 1.
I really want to use the ancestor method.
Can you help a bit ? thank you :)
up ! :)
What have you tried, and what happens?
Ancestors should give you a collection, so in your example
IPublishedContent page1 = Model.Ancestors().First()
should give you Page 1 if you are on Page 2
hello !
I tried that :
but in the html it shows that :
Unfortunatly, that's not the value of the field i'm getting.
I'm not familiar with Fallback, which is what you are actually having an issue with rather than Ancestors.
This is generally why it helps to post code first if you are having a problem, and explain what exactly you are trying to achieve.
From your example it would seem that none of the pages in your ancestry have a value for eventListingPageBanner
The issue to me is that part
<div style="background:@parent.("eventsListingGradient");" class="bannerContent">
This
background:@parent.("eventsListingGradient")
is supposed to give me rgb code to change the background color but instead I have that in the html :background:Umbraco.Web.PublishedModels.EvenementsListing.(" eventslistinggradient")
What i want is in the doc type of page 1, the user enter rgb code and it renders on the page. To avoid the user to enter the rbg code many times, I want page 2 to get the value on page 1.
I hope it's clear ahah
try either
@parent.Value<string>("eventsListingGradient") or the same as you have done for the image src Model.Value<string>("eventsListingGradient", fallback: Fallback.ToAncestors)
Thanks a lot, that was what I was missing !
Thank you sir :)
Glad you got it working, could you mark as answered.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.