Sorry for the late reply I was kinda busy. I couldn't paste my code, that's why I send images instead. When write anything after this "<" it deletes everything, which is kinda weird.
But anyway, thanks to you, your code put me in the right direction and it solved my problem
var item in CurrentPage.Children.Where("DocumentTypeAlias == \"testimonials\"")
I only changed two things - the first being that my DocumentTypeAlias had a lowercase "t" - and the second being that you wrote "children.children" two times.
Need help to create a testimonial feature!
Hey Guys,
I want to create a testimonial feature on my website to show my clients review about my service
I want the testimonials to be shown on the home page
I have created a document type called "testimonals" with some properties and I've created a partial view macro called "Testimonial"
This is where I've put it (Home.cshtml):
And this is my macro fil (Testimonial.cshtml):
The code that I have used doesn't work - can someone help me to display the testimonials items on the home.cshtml?
Best regards,
Sharmarke
Hi Sharmarke,
1) First of all, this line doesn't make sense :
If you on Home page - user just CurrentPage, you don't need to go through content tree to find home page.
2) In foreach you can use just
Do you have some errors on the page? Or just empty result?
What about content tree in Umbraco, can you show ?
Cheers,
Oleksandr Skrypnyk
Hi Alex,
I didn't know that - I just took it from a former project. I do not get any kind of errors - only empty results
Here's my content tree:
Did you create macro in Umbraco backoffice? Because you need to create macro before rendering it in razor?
Yes, I did create a marco
Also add please a checker for children nodes, we need to iterate only in Testimonials pages, so we need something like
I think that problem is with nodes without testimonials properties, so when foreach loops through these nodes, it can be crashed.
Where should I put that line of code at?
Is it replaced with this:
Hi Sharmarke,
No, replace in foreach:
Thanks,
Alex
Sharmarke, it would be great to paste code like text, not like image )) it's in your interests.
Hi Alex,
Sorry for the late reply I was kinda busy. I couldn't paste my code, that's why I send images instead. When write anything after this "<" it deletes everything, which is kinda weird.
But anyway, thanks to you, your code put me in the right direction and it solved my problem
I only changed two things - the first being that my DocumentTypeAlias had a lowercase "t" - and the second being that you wrote "children.children" two times.
Thanks mate,
Sharmarke
You are welcome !!!
Cheers
is working on a reply...