Hey everyone, Im really struggling with razor. I managed to display my items in the model (using the embedded content tool by theFARM). but on the main testimonials page I wont to combine all lists into one.
Embed Content Tool (Testimonials) testimonial (multiple textbox) customer (textstring) alsoshow (content picker, this is for my other testimonials plugin)
All the child pages work perfectly showing the items, but I want to combine them all on the main landing page so its like on the website you land on the testimonials page you see them all but once you click on the department you only see those testimonials.
Heres my working code
@using umbraco.MacroEngines; @{ var itemsList = Model.customerTestimonials; <ul> @foreach (var item in itemsList) { var customerItem = item.customer.InnerText; var testimonItem = item.testimonial.InnerText; <li> <p>@testimonItem</p> <p class="quoter">@customerItem</p> </li> } </ul> }
Thats my working version for showing just the department testimonials, but I now need to create one that would show all the departments in random order, I've tried using decendants, children methods but it keeps coming up with DynamicNode containing the values dont exist and am really stuck :(
Thanks very much Gilad.. you are a life saver! I dont suppose you know how to use the content picker tool to display certain items? for example, I want to show this particular testimonial on page X?
Sorry Gilad, i dont think I explained myself what i meant, lol.. am no sure if I understand the response correctly or what am sorry, just been a hetic day in the office. lol
for each testimonial created by the embedded content, it has a content picker value which I want the testimonial to show also on so it shows related information, instead of having to rewrite the testimonials on the departments pages and any other page.
Testimonials -department 1 (with embedded contnet) -department 2 (with embedded content) Deparments - Lesuire - business - deparment example 3
Hey Gilad, Ive not got the both Lists now working, for the main testimonials page (one you provided to work) and the short list of the testimonials (original working). What am trying to do now is like I have a option when adding a new testimonial, if I want this testimonial to be displayed on another page throughout the rest of the website.
Several Lists combined to one in razor
Hey everyone, Im really struggling with razor. I managed to display my items in the model (using the embedded content tool by theFARM). but on the main testimonials page I wont to combine all lists into one.
Embed Content Tool (Testimonials)
testimonial (multiple textbox)
customer (textstring)
alsoshow (content picker, this is for my other testimonials plugin)
Structure
Testmonials.aspx (parent)
- Department1.aspx (child w/ embed content)
- Department2.aspx (child w/ embed content)
- Department3.aspx (child w/ embed content)
All the child pages work perfectly showing the items, but I want to combine them all on the main landing page so its like on the website you land on the testimonials page you see them all but once you click on the department you only see those testimonials.
Heres my working code
Thats my working version for showing just the department testimonials, but I now need to create one that would show all the departments in random order, I've tried using decendants, children methods but it keeps coming up with DynamicNode containing the values dont exist and am really stuck :(
Hi paul.
in testimonials you can make foreeach loop on children and then use same code..
try this :
Thank Gilad! but i am getting this error through umbraco.
Error occured
Unexpected "foreach" keyword after "@" character. Once inside code, you do not need to prefix constructs like "foreach" with "@".
remove the first @ before the first foreach.
that acourd becuse you open code block with @{
and then if there is no open HTML TAG like in your second loop ( <ul> ) you dont need to put @ before the foreach.
Cheers.
Thanks very much Gilad.. you are a life saver! I dont suppose you know how to use the content picker tool to display certain items? for example, I want to show this particular testimonial on page X?
if you want to do it via content picker (from page X - with content picker property)
you can do something like this :
add : @inherits umbraco.MacroEngines.DynamicNodeContext to the top of the macro.
then :
dynamic testamonialsNode = new DynamicNode(Model."contentPickerPropertyAlias");
then same loop -
Hope that help
Sorry Gilad, i dont think I explained myself what i meant, lol.. am no sure if I understand the response correctly or what am sorry, just been a hetic day in the office. lol
for each testimonial created by the embedded content, it has a content picker value which I want the testimonial to show also on so it shows related information, instead of having to rewrite the testimonials on the departments pages and any other page.
Testimonials
-department 1 (with embedded contnet)
-department 2 (with embedded content)
Deparments
- Lesuire
- business
- deparment example 3
See if i want to randomise the sort the order? how would I achieve that?
Hii paul,
i am not sure that i am understand exactly what you are trying to do...
if you want to disply the same list like in Testimonials page you should get the Testimonials node for getting hes childrens.
Like you use :
So you need to get the node for use :
for example you can use the id of this node :
Hey Gilad, Ive not got the both Lists now working, for the main testimonials page (one you provided to work) and the short list of the testimonials (original working). What am trying to do now is like I have a option when adding a new testimonial, if I want this testimonial to be displayed on another page throughout the rest of the website.
is working on a reply...