Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Nathan Reece 62 posts 376 karma points
    Jul 20, 2020 @ 09:55
    Nathan Reece
    0

    How to Render Staff Profiles to the home page in Umbraco 8

    I have created some staff profile Doc Types and a Staff Folder of where to store them, But i am not to sure how I Display my content as a Partial View so I can Then Render them to the home page?

    Any help or Advice would be great.

  • David Armitage 510 posts 2081 karma points
    Jul 20, 2020 @ 10:05
    David Armitage
    0

    Hi Nathan,

    I am assuming you have create a content item and using it as a folder to store the staff profiles? If so you can you it like this.

    I have copied some of my code from another project so in this case I did it for specializations but essentially it should be the same.

    • First in your template use the Umbraco helper to get the data.
    List<Specialisation> specialisations = Umbraco.Content(1928).Children<Specialisation>().ToList();
    

    So the Id is the id of the specialisations folder. In your case I am assuming this will be your staffProfilesFolder node Id.

    • Once you have a list of staff profiles you can add a loop in your razor script. Something liek this.
    @if (specialisations != null && specialisations.Count() > 0)
    {
        foreach (Specialisation specialisation in specialisations)
        {
            <div class="col-md-4 col-sm-6">
                <div class="rounBox">
                    @if (specialisation.Icon != null)
                    {
                        @PropertyHelper.OptimizeImage(specialisation.Icon,
    Model.BaseViewModel.SiteSettings.EnableWebPimage,
    Model.BaseViewModel.SiteSettings.EnableLazyloadImages,
     specialisation.Title + " Icon", null, "imge1")
                    }
                    <h4>@specialisation.Title</h4>
                    @if (specialisation.Link != null)
                    {
                        <a href="@specialisation.Link.Url" target="@specialisation.Link.Target"></a>
                    }
                </div>
            </div>
        }
    }
    

    Regards

    David

Please Sign in or register to post replies

Write your reply to:

Draft