Skip to content

Commit a00582e

Browse files
committed
Added details of multiple segments per document
1 parent d79d6c8 commit a00582e

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

15/umbraco-cms/reference/routing/request-pipeline/outbound-pipeline.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,30 @@ To explain things we will use the following content tree:
1616

1717
## 1. Create segments
1818

19-
When the URL is constructed, Umbraco will convert every node in the tree into a segment. Each published Content item has a corresponding URL segment.
19+
When the URL is constructed, Umbraco will convert every document node in the tree into a segment. Each published document has a corresponding URL segment.
2020

2121
In our example "Our Products" will become "our-products" and "Swibble" will become "swibble".
2222

2323
The segments are created by the "Url Segment provider"
2424

2525
### Url Segment Provider
2626

27-
The DI container of an Umbraco implementation contains a collection of `UrlSegmentProviders`. This collection is populated during Umbraco boot up. Umbraco ships with a 'DefaultUrlSegmentProvider' - but custom implementations can be added to the collection.
27+
The DI container of an Umbraco implementation contains a collection of `UrlSegmentProviders`. This collection is populated during Umbraco start up. Umbraco ships with a `DefaultUrlSegmentProvider` and custom implementations can be added to the collection.
2828

29-
When the `GetUrlSegment` extension method is called for a content item + culture combination, each registered `IUrlSegmentProvider` in the collection is executed in 'collection order'. This continues until a particular `UrlSegmentProvider` returns a segment value for the content, and no further `UrlSegmentProviders` in the collection will be executed. If no segment is returned by any provider in the collection a `DefaultUrlSegmentProvider` will be used to create a segment. This ensures that a segment is always created, like when a default provider is removed from a collection without a new one being added.
29+
When the segments are requested for a document and culture combination, each registered `IUrlSegmentProvider` in the collection is executed in 'collection order'. Each provider can provide a segment for the document and culture, or return null.
30+
31+
Each URL segment provider is configured to either terminate after providing a segment or to allow other segments providers to be executed. When a terminating provider return a segment value for the document and culture, no further `UrlSegmentProviders` in the collection will be executed.
32+
33+
If the provider does not terminate, other providers are able to return segments as well. In this way, multiple segments can be returned for a single document and culture combination. Along with the use of custom `IUrlProvider` and `IContentFinder` instances, considerable flexibility in the generated URLs can be achieved.
34+
35+
If no segment is returned by any provider in the collection a `DefaultUrlSegmentProvider` will be used to create a segment. This ensures that a segment is always created, even when a default provider is removed from a collection without a new one being added.
3036

3137
To create a new Url Segment Provider, implement the following interface:
3238

3339
```csharp
3440
public interface IUrlSegmentProvider
3541
{
42+
bool AllowAdditionalSegments => false;
3643
string GetUrlSegment(IContentBase content, string? culture = null);
3744
}
3845
```
@@ -59,7 +66,7 @@ public class ProductPageUrlSegmentProvider : IUrlSegmentProvider
5966
{
6067
_provider = new DefaultUrlSegmentProvider(stringHelper);
6168
}
62-
69+
6370
public string GetUrlSegment(IContentBase content, string? culture = null)
6471
{
6572
// Only apply this rule for product pages
@@ -259,7 +266,7 @@ public class ProductPageUrlProvider : NewDefaultUrlProvider
259266
{
260267
return null;
261268
}
262-
269+
263270
// Only apply this to product pages
264271
if (content.ContentType.Alias == "productPage")
265272
{
@@ -270,7 +277,7 @@ public class ProductPageUrlProvider : NewDefaultUrlProvider
270277
{
271278
return null;
272279
}
273-
280+
274281
if (!defaultUrlInfo.IsUrl)
275282
{
276283
// This is a message (eg published but not visible because the parent is unpublished or similar)
@@ -453,7 +460,7 @@ using Umbraco.Cms.Core.Composing;
453460
namespace RoutingDocs.SiteDomainMapping;
454461

455462
public class AddSiteComposer : ComponentComposer<SiteDomainMapperComponent>
456-
{
463+
{
457464
}
458465
```
459466

0 commit comments

Comments
 (0)