Creating a frontpage testimonialslider with repository
Hi guys
Not sure whether the title is descriptive enough but here goes.
I'm working on a company site and on the front page, I'm creating a modal that reveals a slider with customer testimonials.
What I want to do, is make a repository in the root in which it is possible to create new testimonials with:
client logo
clientname
testimonial
link to client case
I did this years ago in umbraco 4, but haven't worked with it since.
I lost my old book from my lvl 1 class, but I'm guessing that's rather obsolete anyways.
I tried Googling for hours, but not sure if I'm even searching for the right thing.
Hope you guys can send me in the right direction, cus I feel rather lost here.
Thank salot for the suggestion.
I've created the doctypes and set it all up. and it renders each item in the MNTP, but my problem is, that it doesn't fetch the data from my testimonial items.
My structure is
MNTP is located on Frontpage with testimonials as property
The view is as follows:
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{ var selection = CurrentPage.testimonials.Split(','); }
<ul id="clientTestimonials">
@foreach (var id in selection)
{
var item = Umbraco.Content(id);
<li class="testimonialWrap">
<div class="testimonialHead">
@if (CurrentPage.HasValue("clientLogo")){
var dynamicMediaItem = Umbraco.Media(CurrentPage.clientLogo);
<img src="@dynamicMediaItem.umbracoFile" alt='@Umbraco.Field("imageAlt")'/>
}
</div>
<div class="testimonialBody">
@Umbraco.Field("clientInfo")
</div>
<div class="testimonialBtn">
@Umbraco.Field("clientTestimonial")
</div>
<a href="@item.Url">@item.Name</a>
</li>
}
</ul>
Could the problem be because both testimonials and frontpage are located in root?
Or am I missing something?
Edit:
I'm prestty sure my problem is, that there's no connection between my MNTP and my Testimonials folder. At least not datawise.
Reason for this is, when I pick items from testimonials folder via the MNTP, they are displayed on the page, but no data from the input fields.
How do you link these together?
Thanks in advance
Henrik
Thank you SO much Ian!!!!
That was a very big help.
On a sidenote. Is there an equivalent to @item. for media, cus I'm not 100% sure how to insert the images since CurrentPage is used in the code I've been using other places on the site..
I've tried several different methods but most end out in Yellow screen of death
Again some of what are doing is correct and some isnt. In my first post i mentioned abot currrntpage i idwntified the line that was correct. With the code you have there should be no further use of currentpage.
Now you need to go back through the code to thinking where does the information originate from that i want to display?
Does the current page in the browser have a client logo property no.
Its the testimonial that has the logo.
Im looping through several testimonials but at the point where my code retrieves the logo image im inside the loop and ive set variable for this testimonial to 'item'.
Therefore any operation you want to perform should be using item. item.hasvalue ... item.clientLogo etc.
Other than that umbraco.media for retrieving images is correct. It is the equivalent of umbraco.content for pages but is only used for media items.
Creating a frontpage testimonialslider with repository
Hi guys
Not sure whether the title is descriptive enough but here goes.
I'm working on a company site and on the front page, I'm creating a modal that reveals a slider with customer testimonials.
What I want to do, is make a repository in the root in which it is possible to create new testimonials with: client logo clientname testimonial link to client case
I did this years ago in umbraco 4, but haven't worked with it since. I lost my old book from my lvl 1 class, but I'm guessing that's rather obsolete anyways.
I tried Googling for hours, but not sure if I'm even searching for the right thing.
Hope you guys can send me in the right direction, cus I feel rather lost here.
Hope you can helkp me out Kind regards Henrik
i am sure there are many way to accomplish this, but in a package-free way, i think something like:
create a 'testimonials folder' doctype create a 'testimonial' doctype
create the testimonial folder in a shared content node outside the site, so they do not appear in the site structure, or hidden somewhere in the site.
add the testimonials to this node
on your homepage doctype, add a MNTP property with its root selction point as the testimonials folder node
on the homepage template, add a partial view to list the contents of the MNTP
Thank salot for the suggestion. I've created the doctypes and set it all up. and it renders each item in the MNTP, but my problem is, that it doesn't fetch the data from my testimonial items. My structure is
Root
-Frontpage
--other stuff
--other stuff
-Testimonials
--Testimonial1
--Testimonial2
--Testimonial3
MNTP is located on Frontpage with testimonials as property
The view is as follows:
Could the problem be because both testimonials and frontpage are located in root?
Or am I missing something?
Edit:
I'm prestty sure my problem is, that there's no connection between my MNTP and my Testimonials folder. At least not datawise.
Reason for this is, when I pick items from testimonials folder via the MNTP, they are displayed on the page, but no data from the input fields.
How do you link these together?
Thanks in advance
Henrik
When you are doing this
you are retrieving a dynamic representation of IPublishedContent the model that sits behind the testimonial (and all published pages in umbraco)
CurrentPage however is the dynamic representation of the page currently being viewed in the browser
Umbraco.Field(.. gets the value of a field existing on the current page in the browser only.
This mean this bit is correct
This bit isn't
Instead this ...
would display the value of the clientInfo field when it exists on the testimonial
Thank you SO much Ian!!!!
That was a very big help.
On a sidenote. Is there an equivalent to @item. for media, cus I'm not 100% sure how to insert the images since CurrentPage is used in the code I've been using other places on the site.. I've tried several different methods but most end out in Yellow screen of death
Again some of what are doing is correct and some isnt. In my first post i mentioned abot currrntpage i idwntified the line that was correct. With the code you have there should be no further use of currentpage.
Now you need to go back through the code to thinking where does the information originate from that i want to display?
Does the current page in the browser have a client logo property no.
Its the testimonial that has the logo.
Im looping through several testimonials but at the point where my code retrieves the logo image im inside the loop and ive set variable for this testimonial to 'item'.
Therefore any operation you want to perform should be using item. item.hasvalue ... item.clientLogo etc.
Other than that umbraco.media for retrieving images is correct. It is the equivalent of umbraco.content for pages but is only used for media items.
Once again thank you very much Ian
I finally got it working
Hi Henrik,
Just for information strongly typed variant, but without using ModelBuilder:
Best,
Oleksandr
is working on a reply...