Developer forum

Forum » Templates » ItemPublisher:Items.List max 10 items

ItemPublisher:Items.List max 10 items

Morgan Fallbrink
Reply

Hi,
we are using an ItemPublisher that is using the "Select items under the following pages" option to pick items.

Using this code in the list:
@using Dynamicweb.Modules.UserManagement;
@using Dynamicweb.Modules.Common.CustomFields;
<div class="items">
    @functions{
        public static CustomFieldValue GetUserCustomFieldValue(string systemName)
        {
            return (from u in User.GetCurrentUser().CustomFieldValues
                    where u.CustomField.SystemName == systemName
                    select u).FirstOrDefault();

        }
    }
    @{
        @*<pre>@string.Join("\n", Values.Select(e => string.Format("{0}: {1}", e.Key, System.Web.HttpUtility.HtmlEncode(e.Value))).ToArray())</pre>*@
    var hasItems = GetBoolean("ItemPublisher:Items.Any");
    var cfvBranschspar = GetUserCustomFieldValue("AccessUser_Branschspar");
    var branschspar = cfvBranschspar != null ? cfvBranschspar.Value as string : "null";
}
    @if (hasItems)
    {
        var list = GetLoop("ItemPublisher:Items.List");
        // For testing
        <pre>@list.Count</pre>
        @*<pre>@string.Join("\n", Values.Select(e => string.Format("{0}: {1}", e.Key, System.Web.HttpUtility.HtmlEncode(e.Value))).ToArray())</pre>*@
        foreach (var item in list)
        {
            @*<pre>@string.Join("\n", item.Values.Select(e => string.Format("{0}: {1}", e.Key, System.Web.HttpUtility.HtmlEncode(e.Value))).ToArray())</pre>*@
            if (branschspar == item.GetString("ItemPublisher:Item.Title"))
            {
                var itemTitle = item.GetString("ItemPublisher:Item.Title");
                var itemTitleShort = itemTitle;
                if (itemTitle.Length > 20)
                {
                    itemTitleShort = itemTitle.Substring(0, 17) + "..";
                }
                var starttid = item.GetDate("ItemPublisher:Item.Starttid");
                var sluttid = item.GetDate("ItemPublisher:Item.Sluttid");
                <div data-role="collapsible" data-inset="false" data-collapsed-icon="carat-r" data-expanded-icon="carat-l">
                    <h3 data-starttime="@starttid.ToString("yyyy/MM/dd HH:mm")" data-endtime="@sluttid.ToString("yyyy/MM/dd HH:mm")" class="defattalize"><span class="eventTime">@starttid.ToString("HH:mm") - @sluttid.ToString("HH:mm")</span> @itemTitleShort</h3>
                    <div class="eventTitle">@itemTitle</div>
                    <div class="eventDetails">@starttid.ToString("HH:mm") - @sluttid.ToString("HH:mm") (@item.GetString("ItemPublisher:Item.Plats"))</div>
                    <p>
                        @item.GetString("ItemPublisher:Item.BeskrivandeText")<br /><br />
                    </p>
                </div>
            }
        }
    }
</div>

If we add just one page with 3-4 items in the "Select items under.." options. Everything is peachy and the right item is selected.
But when the number of total items rises to above 10 only 10 are in the loop and it's abit random if my item is among those 10.

Can anyone shed some light on this?


Replies

 
Mikkel Ricky
Reply
This post has been marked as an answer

This is caused by a weird bug in the handling of loops in Razor templates. It has been fixed in Dynamicweb 8.4.1. Please upgrade if possible.

Best regards,
Mikkel

Votes for this answer: 1
 
Morgan Fallbrink
Reply

Hi again, upgraded and the problem is still there. Can I get a version and name of the updated dll so I can double check I didn't miss anything?

 
Mikkel Ricky
Reply
This post has been marked as an answer

The updated dlls are in the download you can find on our download page: http://developer.dynamicweb-cms.com/downloads/dynamicweb-8.aspx.

What's the value of the Page size setting in your item publisher module settings?

Best regards,
Mikkel

Votes for this answer: 1
 
Morgan Fallbrink
Reply

Thanks Mikkel, page size was set to 10. The combo solution worked. Update and change page size.

 

You must be logged in to post in the forum