PHPackages                             mak001/silverstripe-categorization - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. mak001/silverstripe-categorization

ActiveSilverstripe-vendormodule[Utility &amp; Helpers](/categories/utility)

mak001/silverstripe-categorization
==================================

SilverStripe Categorization Module. Easily allows categorization to be added to Pages and DataObjects.

128[1 issues](https://github.com/mak001/silverstripe-categorization/issues)PHP

Since Jul 23Pushed 7y ago1 watchersCompare

[ Source](https://github.com/mak001/silverstripe-categorization)[ Packagist](https://packagist.org/packages/mak001/silverstripe-categorization)[ RSS](/packages/mak001-silverstripe-categorization/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

SilverStripe Categorization
===========================

[](#silverstripe-categorization)

[![Build Status](https://camo.githubusercontent.com/2f0766b6fa4ed83498a63c433530858618a43952a11c1a4e19d461e52f339096/68747470733a2f2f7472617669732d63692e6f72672f6d616b3030312f73696c7665727374726970652d63617465676f72697a6174696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mak001/silverstripe-categorization)[![codecov](https://camo.githubusercontent.com/368a6fe715d3defaca338d75ee7600d88511ec578900986a1fd2f73a62debb50/68747470733a2f2f636f6465636f762e696f2f67682f6d616b3030312f73696c7665727374726970652d63617465676f72697a6174696f6e2f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/mak001/silverstripe-categorization)

Easily add categorization to Pages or DataObjects and allow categories to be accessed by a nice url.

Take a page on `example.com` with the url segment `page` with a relation named `Categories`.

Categories can be accessed by visiting `example.com/page/Categories`.

Going to `example.com/page/Categories/category` will return a categorization in the `Categories` relation with the `URLSegment` of `category`.

Requirements
------------

[](#requirements)

- SilverStripe 4.0

Installation
------------

[](#installation)

`composer require mak001/silverstripe-categorization`

Usage
-----

[](#usage)

### CategorizationExtension

[](#categorizationextension)

To create a category add `Mak001\Categorization\Extensions\CategorizationExtension` to a DataObject. This extension will add a `Title` and `URLSegment` fields to the DataObject.

```
Category:
  extensions:
    - Mak001\Categorization\Extensions\CategorizationExtension
```

### CategorizationControllerExtension

[](#categorizationcontrollerextension)

Allows a page to show category relations. This will pick up `has_many`, `many_many`, and `belongs_many_many` relations if the relation class has the `CategorizationExtension` applied.

```
CategoryPageController:
  extensions:
    - Mak001\Categorization\Extensions\CategorizationControllerExtension
```

#### External Relations

[](#external-relations)

External relations can also be made viewable. This is useful when children of a holder page have the relations, but the holder should have the viewable relations. This can be done with

```
private static $external_relation = [
    'External' => RelationClass::class,
];

public function External()
{
    return RelationClass::get();
}
```

All external relations require a method named the same as the relation name.

#### Relation url segments

[](#relation-url-segments)

Relation segments can be different than the relation name. An example of the is the `Categories` relation mapping to `categories`. Simply add

```
private static $relation_segments = [
    'Categories' => 'example_segment',
];
```

Now visiting `example.com/page/example_segment` will point to the `Categories` relation, and `example.com/page/Categories` will not be found.

It will default to the relation name.

### Templating

[](#templating)

Take a page type `NameSpace/CategoryPage` that extends `Page` with the url segment of `page`. When visiting `example.com/page/Categories` the templates that can be used are

```
[
    "NameSpace/CategoryPage_Categories",
    "Page_Categories",
    "NameSpace/CategoryPage",
    "Page",
]
```

It will always look for `ClassName_Relation`, never for the `relation_segment` for the relation.

With a categorization object with a `singular_name` of `Category` and a `url_segment` of `category`, when visiting `example.com/page/Categories/category` the templates that can be used are

```
[
    "NameSpace/CategoryPage_Categories_Category",
    "Page_Categories_Category",
    "NameSpace/CategoryPage_Categories",
    "Page_Categories",
    "NameSpace/CategoryPage",
    "Page",
]
```

These should be located in the `Layouts` folder.

When visiting a relation link the template will be passed a `Categorizations` variable that will contain the categories in the relation.

When visiting `example.com/page/Categories/category` the templates will be the same as above. A `Categorization` variable will be added that will contain the categorization with the given URLSegment in the specified relation.

When visiting either a relation link or a categorization object the template will be passed a `RelationName` variable that denotes what relation is currently being viewed.

#### Non generic variables

[](#non-generic-variables)

Setting `$use_alternative_variables` to true on the controller will use the relation names and the categorization `$singlur_name` in place of the generic `Categorizations` and `Categorization` variable names respectivly.

### Modifying the relation lists

[](#modifying-the-relation-lists)

Modify the lists passed to the template using the generic `modifyCategorizationList($list, $request)` extension point. THis will apply to all lists. To have more fine tuned controll over specific relation lists use `modify{$relationName}List()` replacing `{$relationName}` with the name of the relation.

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/0f0d16f19b9e6a20a55ed355774bb414fcfc88d95cfbd2f978cd5afa927d4d7c?d=identicon)[mak001](/maintainers/mak001)

---

Top Contributors

[![mak001](https://avatars.githubusercontent.com/u/1750550?v=4)](https://github.com/mak001 "mak001 (13 commits)")

### Embed Badge

![Health badge](/badges/mak001-silverstripe-categorization/health.svg)

```
[![Health](https://phpackages.com/badges/mak001-silverstripe-categorization/health.svg)](https://phpackages.com/packages/mak001-silverstripe-categorization)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
