This repository has been archived by the owner on Nov 19, 2020. It is now read-only.
-
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.
Added tags property to blog posts Added dynamic url handling with UmbracoVirtualNodeByIdRouteHandler to show all tags and all content related to a tag
- Loading branch information
Showing
13 changed files
with
215 additions
and
5 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
C:\Users\mantu\AppData\Local\Temp\Temporary ASP.NET Files\vs\027ab051\822a0174\App_Web_all.generated.cs.8f9494c4.oibqrept.dll | ||
C:\Users\brendeld\AppData\Local\Temp\Temporary ASP.NET Files\vs\db0e3ea5\41b4334d\App_Web_all.generated.cs.8f9494c4.feq1txiv.dll |
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
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
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 |
---|---|---|
@@ -1 +1 @@ | ||
e4d2aa0bdb7a3315 | ||
4ad86b1aa0722510 |
Binary file not shown.
42 changes: 42 additions & 0 deletions
42
src/UmbracoUrlHandling/Controller/BlogPostRepositoryController.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,42 @@ | ||
using System.Linq; | ||
using System.Web.Mvc; | ||
using Umbraco.Web.Models; | ||
using Umbraco.Web.Mvc; | ||
using UmbracoUrlHandling.Models; | ||
|
||
namespace UmbracoUrlHandling.Controller | ||
{ | ||
/// <summary> | ||
/// Route hijacking using controller to handle custom model building for templates | ||
/// </summary> | ||
/// <seealso cref="Umbraco.Web.Mvc.RenderMvcController" /> | ||
public class BlogPostRepositoryController : RenderMvcController | ||
{ | ||
/// <summary> | ||
/// Method to show tags overview template. | ||
/// </summary> | ||
/// <param name="model">The model.</param> | ||
/// <returns></returns> | ||
public ActionResult Categories(RenderModel model) | ||
{ | ||
var tags = Services.TagService.GetAllContentTags().ToList(); | ||
var viewModel = new TagsOverviewViewModel(model.Content) {Tags = tags}; | ||
return View("TagsOverview", viewModel); | ||
} | ||
|
||
/// <summary> | ||
/// Shows all content that was tagged with a specific category. | ||
/// </summary> | ||
/// <param name="model">The model.</param> | ||
/// <param name="category">The category.</param> | ||
/// <returns></returns> | ||
public ActionResult Category(RenderModel model, string category) | ||
{ | ||
var tagsService = Services.TagService; | ||
var relatedContentTaggedEntities = tagsService.GetTaggedContentByTag(category); | ||
var relatedContent = Umbraco.TypedContent(relatedContentTaggedEntities.Select(x => x.EntityId)); | ||
var viewModel = new CategoryContentViewModel(model.Content) { Category = category, RelatedContentForCategory = relatedContent}; | ||
return View("RelatedContentForCategory", viewModel); | ||
} | ||
} | ||
} |
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,37 @@ | ||
using System.Collections.Generic; | ||
using Umbraco.Core.Models; | ||
using Umbraco.Core.Models.PublishedContent; | ||
|
||
namespace UmbracoUrlHandling.Models | ||
{ | ||
/// <summary> | ||
/// ViewModel to render all content for aspecific category | ||
/// </summary> | ||
/// <seealso cref="Umbraco.Core.Models.PublishedContent.PublishedContentWrapped" /> | ||
public class CategoryContentViewModel : PublishedContentWrapped | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="CategoryContentViewModel"/> class. | ||
/// </summary> | ||
/// <param name="content">The content to wrap and extend.</param> | ||
public CategoryContentViewModel(IPublishedContent content) : base(content) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the category. | ||
/// </summary> | ||
/// <value> | ||
/// The category. | ||
/// </value> | ||
public string Category { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the related content for category. | ||
/// </summary> | ||
/// <value> | ||
/// The related content for category. | ||
/// </value> | ||
public IEnumerable<IPublishedContent> RelatedContentForCategory { get; set; } | ||
} | ||
} |
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,29 @@ | ||
using System.Collections.Generic; | ||
using Umbraco.Core.Models; | ||
using Umbraco.Core.Models.PublishedContent; | ||
|
||
namespace UmbracoUrlHandling.Models | ||
{ | ||
/// <summary> | ||
/// View model for tags overview of blog posts | ||
/// </summary> | ||
/// <seealso cref="Umbraco.Core.Models.PublishedContent.PublishedContentWrapped" /> | ||
public class TagsOverviewViewModel : PublishedContentWrapped | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="TagsOverviewViewModel"/> class. | ||
/// </summary> | ||
/// <param name="content">The content to wrap and extend.</param> | ||
public TagsOverviewViewModel(IPublishedContent content) : base(content) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the tags. | ||
/// </summary> | ||
/// <value> | ||
/// The tags. | ||
/// </value> | ||
public IEnumerable<ITag> Tags { get; set; } | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/UmbracoUrlHandling/RouteHandler/BlogRepositoryRouteHandler.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,19 @@ | ||
using Umbraco.Web.Mvc; | ||
|
||
namespace UmbracoUrlHandling.RouteHandler | ||
{ | ||
/// <summary> | ||
/// BlogPostRepositoryrouteHandler to handle routes to BlogPostRepository | ||
/// </summary> | ||
/// <seealso cref="Umbraco.Web.Mvc.UmbracoVirtualNodeByIdRouteHandler" /> | ||
public class BlogRepositoryRouteHandler : UmbracoVirtualNodeByIdRouteHandler | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="BlogRepositoryRouteHandler"/> class. | ||
/// </summary> | ||
/// <param name="realNodeId">The real node identifier.</param> | ||
public BlogRepositoryRouteHandler(int realNodeId) : base(realNodeId) | ||
{ | ||
} | ||
} | ||
} |
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
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
14 changes: 14 additions & 0 deletions
14
src/UmbracoUrlHandling/Views/RelatedContentForCategory.cshtml
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,14 @@ | ||
@inherits UmbracoViewPage<UmbracoUrlHandling.Models.CategoryContentViewModel> | ||
@{ | ||
Layout = "Master.cshtml"; | ||
} | ||
|
||
<h1>Pages related to category "@Model.Category":</h1> | ||
<ul> | ||
@foreach (var content in Model.RelatedContentForCategory) | ||
{ | ||
<li> | ||
<a href="@content.Url">@content.Name</a> | ||
</li> | ||
} | ||
</ul> |
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,13 @@ | ||
@inherits UmbracoViewPage<UmbracoUrlHandling.Models.TagsOverviewViewModel> | ||
@{ | ||
Layout = "Master.cshtml"; | ||
} | ||
|
||
<h1>All tags</h1> | ||
|
||
<ul> | ||
@foreach (var tag in Model.Tags) | ||
{ | ||
<li><a href="@Model.Url.EnsureEndsWith("/")category/@tag.Text">@tag.Text</a></li> | ||
} | ||
</ul> |