Added a part setting for TermPart so the page size can be adjusted.

This commit is contained in:
Bertrand Le Roy
2014-01-18 19:43:08 -08:00
parent 529a43c1ed
commit cc9624c741
4 changed files with 34 additions and 3 deletions

View File

@@ -59,6 +59,10 @@ namespace Orchard.Taxonomies.Drivers {
var totalItemCount = _taxonomyService.GetContentItemsCount(part);
var partSettings = part.Settings.GetModel<TermPartSettings>();
if (partSettings != null && partSettings.OverrideDefaultPagination) {
pager.PageSize = partSettings.PageSize;
}
var childDisplayType = partSettings != null &&
!String.IsNullOrWhiteSpace(partSettings.ChildDisplayType)
? partSettings.ChildDisplayType
@@ -72,7 +76,9 @@ namespace Orchard.Taxonomies.Drivers {
list.AddRange(termContentItems);
var pagerShape = shapeHelper.Pager(pager)
var pagerShape = pager.PageSize == 0
? null
: shapeHelper.Pager(pager)
.TotalItemCount(totalItemCount)
.Taxonomy(taxonomy)
.Term(part);

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Globalization;
using Orchard.ContentManagement;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.MetaData.Builders;
@@ -23,7 +24,9 @@ namespace Orchard.Taxonomies.Settings {
if (updateModel.TryUpdateModel(model, "TermPartSettings", null, null)) {
builder
.WithSetting("TermPartSettings.ChildDisplayType", model.ChildDisplayType);
.WithSetting("TermPartSettings.ChildDisplayType", model.ChildDisplayType)
.WithSetting("TermPartSettings.OverrideDefaultPagination", model.OverrideDefaultPagination.ToString())
.WithSetting("TermPartSettings.PageSize", model.PageSize.ToString(CultureInfo.InvariantCulture));
}
yield return DefinitionTemplate(model);

View File

@@ -4,5 +4,15 @@
/// The display type to use for the child items of the term.
/// </summary>
public string ChildDisplayType { get; set; }
/// <summary>
/// If true, overrides default pagination settings with the PageSize value.
/// </summary>
public bool OverrideDefaultPagination { get; set; }
/// <summary>
/// The page size, if OverrideDefaultPagination is set to true.
/// </summary>
public int PageSize { get; set; }
}
}

View File

@@ -4,4 +4,16 @@
@Html.TextBoxFor(m => m.ChildDisplayType, new { @class = "text medium" })
<span class="hint">@T("The display type to apply to child items when displaying the details of this taxonomy term.")</span>
@Html.ValidationMessageFor(m => m.ChildDisplayType)
</fieldset>
</fieldset>
<fieldset>
<label>@T("Pagination")</label>
<div class="content">
@Html.CheckBoxFor(m => m.OverrideDefaultPagination)
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.OverrideDefaultPagination)">@T("Override the default page size")</label>
</div>
<div data-controllerid="@Html.FieldIdFor(m => m.OverrideDefaultPagination)">
<label for="@Html.FieldIdFor(m => m.PageSize)">@T("Number of items per page")</label>
@Html.TextBoxFor(m => m.PageSize, new { @class = "text small" })
<span class="hint">@T("Determines the number of items that are shown per page.")</span>
</div>
</fieldset>