Copied to clipboard

Flag this post as spam?

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


  • James 251 posts 1169 karma points
    Jul 28, 2014 @ 15:42
    James
    0

    Cant display items

    Consider the following code:

    @{

        var pageSize = 1;

        var page = 1; int.TryParse(Request.QueryString["page"], out page);

        var items = Umbraco.TypedContent(Model.Content.Id).Children.Where(x => x.DocumentTypeAlias == "PortfolioItem" && x.IsVisible());

        var totalPages = (int)Math.Ceiling((double)items.Count() / (double)pageSize);

     

        if (page > totalPages)

        {

            page = totalPages;

        }

        else if (page < 1)

        {

            page = 1;

        }

     

    }

    @foreach (var item in items.Skip((page - 1) * pageSize).Take(pageSize).OrderBy(x => x.Name))

    {

            @item.PortfolioItemCoverPhoto

    }

    I get a YSOD on the line @item.PortfolioItemCoverPhoto

     

    Why cant I display document type attributes of my portfolio items? (There are currently two portfolio items with various attributes of PotfolioItem*****").

     

    Thanks for any input. 

    Kind regards.

  • James 251 posts 1169 karma points
    Jul 28, 2014 @ 15:54
    James
    0

    The YSOD:

    CS1061: 'Umbraco.Core.Models.IPublishedContent' does not contain a definition for 'PortfolioItemCoverPhoto' and no extension method 'PortfolioItemCoverPhoto' accepting a first argument of type 'Umbraco.Core.Models.IPublishedContent' could be found (are you missing a using directive or an assembly reference?)

  • James 251 posts 1169 karma points
    Jul 28, 2014 @ 16:22
    James
    100

    Its ok figured it out.

     

    Access the item properities using:

     @item.GetPropertyValue("PortfolioItemCoverPhoto")

Please Sign in or register to post replies

Write your reply to:

Draft