forked from OrchardCMS/OrchardCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
widget alternates dependent on orchardcore.widgets module
- Loading branch information
Showing
8 changed files
with
160 additions
and
82 deletions.
There are no files selected for viewing
40 changes: 0 additions & 40 deletions
40
src/OrchardCore.Modules/OrchardCore.Alias/Services/AliasShapeTableProvider.cs
This file was deleted.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
src/OrchardCore.Modules/OrchardCore.Alias/Services/ContentAliasShapeTableProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using OrchardCore.Alias.Models; | ||
using OrchardCore.ContentManagement; | ||
using OrchardCore.DisplayManagement; | ||
using OrchardCore.DisplayManagement.Descriptors; | ||
using OrchardCore.DisplayManagement.Utilities; | ||
|
||
namespace OrchardCore.Alias.Services; | ||
|
||
public class ContentAliasShapeTableProvider : ShapeTableProvider | ||
{ | ||
public override ValueTask DiscoverAsync(ShapeTableBuilder builder) | ||
{ | ||
builder.Describe("Content") | ||
.OnDisplaying(displaying => | ||
{ | ||
var shape = displaying.Shape; | ||
var contentItem = shape.GetProperty<ContentItem>("ContentItem"); | ||
var aliasPart = contentItem?.As<AliasPart>(); | ||
if (aliasPart != null) | ||
{ | ||
var encodedAlias = aliasPart.Alias.EncodeAlternateElement(); | ||
// Content__Alias__[Alias] e.g. Content-Alias-example, Content-Alias-my-page | ||
displaying.Shape.Metadata.Alternates.Add("Content__Alias__" + encodedAlias); | ||
// Content_[DisplayType]__Alias__[Alias] e.g. Content-Alias-example.Summary, Content-Alias-my-page.Summary | ||
displaying.Shape.Metadata.Alternates.Add("Content_" + displaying.Shape.Metadata.DisplayType + "__Alias__" + encodedAlias); | ||
} | ||
}); | ||
|
||
return ValueTask.CompletedTask; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/OrchardCore.Modules/OrchardCore.Alias/Services/WidgetAliasShapeTableProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using OrchardCore.Alias.Models; | ||
using OrchardCore.ContentManagement; | ||
using OrchardCore.DisplayManagement; | ||
using OrchardCore.DisplayManagement.Descriptors; | ||
using OrchardCore.DisplayManagement.Utilities; | ||
|
||
namespace OrchardCore.Alias.Services; | ||
|
||
public class WidgetAliasShapeTableProvider : ShapeTableProvider | ||
{ | ||
public override ValueTask DiscoverAsync(ShapeTableBuilder builder) | ||
{ | ||
builder.Describe("Widget") | ||
.OnDisplaying(displaying => | ||
{ | ||
var shape = displaying.Shape; | ||
var contentItem = shape.GetProperty<ContentItem>("ContentItem"); | ||
var aliasPart = contentItem?.As<AliasPart>(); | ||
if (aliasPart != null) | ||
{ | ||
var encodedAlias = aliasPart.Alias.EncodeAlternateElement(); | ||
// Widget__Alias__[Alias] e.g. Widget-Alias-example, Content-Alias-my-page | ||
displaying.Shape.Metadata.Alternates.Add("Widget__Alias__" + encodedAlias); | ||
// Widget_[DisplayType]__Alias__[Alias] e.g. Widget-Alias-example.Summary, Widget-Alias-my-page.Summary | ||
displaying.Shape.Metadata.Alternates.Add("Widget_" + displaying.Shape.Metadata.DisplayType + "__Alias__" + encodedAlias); | ||
} | ||
}); | ||
|
||
return ValueTask.CompletedTask; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 0 additions & 40 deletions
40
src/OrchardCore.Modules/OrchardCore.Autoroute/Services/AutorouteShapeTableProvider.cs
This file was deleted.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
src/OrchardCore.Modules/OrchardCore.Autoroute/Services/ContentAutorouteShapeTableProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using OrchardCore.Autoroute.Models; | ||
using OrchardCore.ContentManagement; | ||
using OrchardCore.DisplayManagement; | ||
using OrchardCore.DisplayManagement.Descriptors; | ||
using OrchardCore.DisplayManagement.Utilities; | ||
|
||
namespace OrchardCore.Autoroute.Services; | ||
|
||
public class ContentAutorouteShapeTableProvider : ShapeTableProvider | ||
{ | ||
public override ValueTask DiscoverAsync(ShapeTableBuilder builder) | ||
{ | ||
builder.Describe("Content") | ||
.OnDisplaying(displaying => | ||
{ | ||
var shape = displaying.Shape; | ||
var contentItem = shape.GetProperty<ContentItem>("ContentItem"); | ||
var autoroutePart = contentItem?.As<AutoroutePart>(); | ||
if (autoroutePart != null) | ||
{ | ||
var encodedSlug = autoroutePart.Path.EncodeAlternateElement().Replace("/", "__"); | ||
// Content__Slug__[Slug] e.g. Content-Slug-example, Content-Slug-blog-my-post | ||
displaying.Shape.Metadata.Alternates.Add("Content__Slug__" + encodedSlug); | ||
// Content_[DisplayType]__Slug__[Slug] e.g. Content-Slug-example.Summary, Content-Slug-blog-my-post.Summary | ||
displaying.Shape.Metadata.Alternates.Add("Content_" + displaying.Shape.Metadata.DisplayType + "__Slug__" + encodedSlug); | ||
} | ||
}); | ||
|
||
return ValueTask.CompletedTask; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/OrchardCore.Modules/OrchardCore.Autoroute/Services/WidgetAutorouteShapeTableProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using OrchardCore.Autoroute.Models; | ||
using OrchardCore.ContentManagement; | ||
using OrchardCore.DisplayManagement; | ||
using OrchardCore.DisplayManagement.Descriptors; | ||
using OrchardCore.DisplayManagement.Utilities; | ||
|
||
namespace OrchardCore.Autoroute.Services; | ||
|
||
public class WidgetAutorouteShapeTableProvider : ShapeTableProvider | ||
{ | ||
public override ValueTask DiscoverAsync(ShapeTableBuilder builder) | ||
{ | ||
builder.Describe("Widget") | ||
.OnDisplaying(displaying => | ||
{ | ||
var shape = displaying.Shape; | ||
var contentItem = shape.GetProperty<ContentItem>("ContentItem"); | ||
var autoroutePart = contentItem?.As<AutoroutePart>(); | ||
if (autoroutePart != null) | ||
{ | ||
var encodedSlug = autoroutePart.Path.EncodeAlternateElement().Replace("/", "__"); | ||
// Widget__Slug__[Slug] e.g. Widget-Slug-example, Widget-Slug-blog-my-post | ||
displaying.Shape.Metadata.Alternates.Add("Widget__Slug__" + encodedSlug); | ||
// Widget_[DisplayType]__Slug__[Slug] e.g. Widget-Slug-example.Summary, Widget-Slug-blog-my-post.Summary | ||
displaying.Shape.Metadata.Alternates.Add("Widget_" + displaying.Shape.Metadata.DisplayType + "__Slug__" + encodedSlug); | ||
} | ||
}); | ||
|
||
return ValueTask.CompletedTask; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters