That's easy for me to use since I made the properties on the service document type, therefore I can use just the @Umbraco.Field
My problem is, that I want also the 6 services to display on my home page, but I'm not sure how to achieve that. How do I get access and use my properties from the service document type
So I can get it displayed on the home page. And since they're not child items I can't use method like this one:
var blog = Model.Content.AncestorOrSelf(1).Descendants("blog").FirstOrDefault();
You can get these as you given the code example of blog. i am not seeing any problem to get service node. As you are already on home page so you can use directly descendants.
var servicePage = Model.Content.Descendants("yourservice").FirstOrDefault();
It can also solve in another way like
Create a property named service page at home page with use of content picker control.
Get the value of service page like
var servicePage = Umbraco.TypedContent(Model.Content.GetPropertyValue
@servicePage.GetPropertyValue("yourproperty")
Another thing i have noticed that you have created the six property like "serviceTitle1", "serviceTitle2" as you mentioned.
What happened if customer need 2 more services in future so you will create the 2 more properties. right? then customer has no control over it but dependent on you.
I suggest that you many use Archetype OR create service page where each page represent single service. then customer can create as many services they want.
CS1061: 'Umbraco.Core.Models.IPublishedContent' does not contain a definition for 'serviceTitle3' and no extension method 'serviceTitle3' accepting a first argument of type 'Umbraco.Core.Models.IPublishedContent' could be found (are you missing a using directive or an assembly reference?
Getting information from one page and display it on another, help!
Hi guys!
I ran into a problem. What I'm talking about is two pages, the home page and a service page.
I've 6 services like this displayed on my service site:
And the code is like this ex.:
That's easy for me to use since I made the properties on the service document type, therefore I can use just the @Umbraco.Field
My problem is, that I want also the 6 services to display on my home page, but I'm not sure how to achieve that. How do I get access and use my properties from the service document type
So I can get it displayed on the home page. And since they're not child items I can't use method like this one:
I hope my question was understandable
Thanks in advance!
//Sharmarke
Hi,
can u please share ur content tree structure? then it will be easy to help you.
Yasir
Yes of course - here it is:
The one named "ydelser" is the service node
Hi,
You can get these as you given the code example of blog. i am not seeing any problem to get service node. As you are already on home page so you can use directly descendants.
It can also solve in another way like
Get the value of service page like
var servicePage = Umbraco.TypedContent(Model.Content.GetPropertyValue
@servicePage.GetPropertyValue("yourproperty")
Another thing i have noticed that you have created the six property like "serviceTitle1", "serviceTitle2" as you mentioned.
What happened if customer need 2 more services in future so you will create the 2 more properties. right? then customer has no control over it but dependent on you.
I suggest that you many use Archetype OR create service page where each page represent single service. then customer can create as many services they want.
Hopefully it work for you.
Yasir
Hi Yasir,
I know about the names (service 1, service 2 etc.). It's not for a customer, but for myself so it's not a big problem there.
But how can use this one:
When I don't have any descendants. I've created a property named services on my service page.
So do you suggest I should solve the problem with the use of content picker?
Hi,
You are on Home page so Ydelser er the child of home. so you can access it using Descendants OR Descendant
How can you say that it is not the children of home? Please try with descendants first.
Other one was the alternative solution using content picker.
its upto you which one would you like to use.
Yasir
Hi Yasir,
You were right - I wasn't thinking right
I did this:
But I got an error when I did this:
It gives me this error:
CS1061: 'Umbraco.Core.Models.IPublishedContent' does not contain a definition for 'serviceTitle3' and no extension method 'serviceTitle3' accepting a first argument of type 'Umbraco.Core.Models.IPublishedContent' could be found (are you missing a using directive or an assembly reference?
is "ydelser" your document type alias?
Please double check your document type alias
Yasir
Yes, it is my document type alias
hmm!
I am assuming that your code is on home page. right?
can you please also share the screen of your document type ydelser?
Yes, the code is on my home page...
Here it is:
its little strange. looks like every thing is correct
can you check that what is coming in your variable ydelser?
either you may try
lets check that is it iPublishedContent?
I still get the same error
do you have skype id?
can you share it?
Hi Yasir
I made it work somehow - now it's showing what I want it show
I changed this:
To this:
Why do you think this can be the case?
Thats great!
so its mean that direct descentdants was not working.
So you may use like then you have strong type published model instead of dynamic object
Yeah, it makes more since now!
But thank you for helping me out, Yasir!
is working on a reply...