-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autoroute container routing #5665
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
9b21a8f
wip. stil resolving issues with absolute routing and path verification
deanmarcussen 5d71d5e
wip. add setting to autoroute so it knows when it is contained, and c…
deanmarcussen 9d2066e
tweaks
deanmarcussen abc414d
Autohide some ui when it is not required
deanmarcussen eaeffd6
Merge branch 'dev' into deanmarcussen/autoroute-container
deanmarcussen ad59ad7
add home route options, update hints
deanmarcussen f446bc3
add autoroutepart in migrations. remove unused shapes. update settings.
deanmarcussen bb4d164
move to content manager
deanmarcussen 3814a54
Merge branch 'dev' into deanmarcussen/autoroute-container
deanmarcussen ce04b88
wip. term shapes and routing implementation for the blog theme.
deanmarcussen e6c9b4b
Merge branch 'dev' into deanmarcussen/autoroute-container
deanmarcussen 52053c2
Remove tagbuilder from TermItem. Tidy up
deanmarcussen 31fcf33
typos
deanmarcussen 596b5a9
add docs for autoroute
deanmarcussen 134a1ea
Merge branch 'dev' into deanmarcussen/autoroute-container
deanmarcussen bb09b1e
Feedback
deanmarcussen b4de45b
Respond to feedback
deanmarcussen 7da60c2
Update term shape alternates
deanmarcussen 37a0ab3
minor change
deanmarcussen 056d683
term shape docs
deanmarcussen c6fad89
Merge branch 'dev' into deanmarcussen/autoroute-container
deanmarcussen 38d1263
fix spelling
deanmarcussen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
39 changes: 39 additions & 0 deletions
39
src/OrchardCore.Modules/OrchardCore.Autoroute/Handlers/AutorouteContentHandler.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,39 @@ | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Routing; | ||
using OrchardCore.ContentManagement; | ||
using OrchardCore.ContentManagement.Handlers; | ||
using OrchardCore.ContentManagement.Routing; | ||
|
||
namespace OrchardCore.Autoroute.Handlers | ||
{ | ||
public class AutorouteContentHandler : ContentHandlerBase | ||
{ | ||
private readonly IAutorouteEntries _autorouteEntries; | ||
|
||
public AutorouteContentHandler(IAutorouteEntries autorouteEntries) | ||
{ | ||
_autorouteEntries = autorouteEntries; | ||
} | ||
|
||
public override Task GetContentItemAspectAsync(ContentItemAspectContext context) | ||
{ | ||
return context.ForAsync<ContentItemMetadata>(metadata => | ||
{ | ||
// When a content item is contained we provide different route values when generating urls. | ||
if (_autorouteEntries.TryGetEntryByContentItemId(context.ContentItem.ContentItemId, out var entry) && | ||
!string.IsNullOrEmpty(entry.ContainedContentItemId)) | ||
{ | ||
metadata.DisplayRouteValues = new RouteValueDictionary { | ||
{ "Area", "OrchardCore.Contents" }, | ||
{ "Controller", "Item" }, | ||
{ "Action", "Display" }, | ||
{ "ContentItemId", entry.ContentItemId}, | ||
{ "ContainedContentItemId", entry.ContainedContentItemId } | ||
}; | ||
} | ||
|
||
return Task.CompletedTask; | ||
}); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one side effect is that if contained item routing is not enabled, generating a route for it with a url helper will generate a standard route (i.e. /Contents/Item/id) which will 404