Search code examples
orchardcmsorchardcms-1.8

Set PageSize in a Taxonomy view


I've started my first project using OrchardCMS and so far so good. It's a brilliant piece of kit and amazingly powerful once you get up to speed with the terminology of it.

One area I'm struggling with is displaying Taxonomies. There seems to be almost no documentation on it, and Shape Tracing is not being very useful.

I'm using a taxonomy to display content items that have the same term. This is all working great now, however the default pagination page size is 10 items. I've dug through lots of code and found this is driven from TermPart

    protected override DriverResult Display(TermPart part, string displayType, dynamic shapeHelper) {
        return Combined(
            ContentShape("Parts_TermPart_Feed", () => {

                // generates a link to the RSS feed for this term
                _feedManager.Register(part.Name, "rss", new RouteValueDictionary { { "term", part.Id } });
                return null;
            }),
            ContentShape("Parts_TermPart", () => {
                var pagerParameters = new PagerParameters();
                var httpContext = _httpContextAccessor.Current();
                if (httpContext != null) {
                    pagerParameters.Page = Convert.ToInt32(httpContext.Request.QueryString["page"]);
                }

                var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
                var taxonomy = _taxonomyService.GetTaxonomy(part.TaxonomyId);
                var totalItemCount = _taxonomyService.GetContentItemsCount(part);

                var partSettings = part.Settings.GetModel<TermPartSettings>();
                if (partSettings != null && partSettings.OverrideDefaultPagination) {
                    pager.PageSize = partSettings.PageSize;
                }

The question is where is TermPart & TermPartSettings defined?

Thanks in advance


Solution

  • The TermPartSettings are in the Modules/Orchard.Taxonomies/Settings folder. The TermPart itself is in the Modules/Orchard.Taxonomies/Models directory. Don't know what you want with that information though, because you shouldnt edit an Orchard's module code.

    When you create a new Taxonomy in the dashboard of Orchard, a new content type is created under Content Definition. It is called YourTaxonomy Term. This content type has a setting called 'override the default page size', where you can define your own page size.