diff --git a/extensions/tags/js/forum/dist/extension.js b/extensions/tags/js/forum/dist/extension.js index bbe7b6b81..441360706 100644 --- a/extensions/tags/js/forum/dist/extension.js +++ b/extensions/tags/js/forum/dist/extension.js @@ -150,6 +150,14 @@ System.register('flarum/tags/addTagFilter', ['flarum/extend', 'flarum/components return original(); }); + extend(IndexPage.prototype, 'view', function (vdom) { + var tag = this.currentTag(); + + if (tag) { + vdom.attrs.className += ' IndexPage--tag' + tag.id(); + } + }); + // If currently viewing a tag, restyle the 'new discussion' button to use // the tag's color. extend(IndexPage.prototype, 'sidebarItems', function (items) { diff --git a/extensions/tags/js/forum/src/addTagFilter.js b/extensions/tags/js/forum/src/addTagFilter.js index 5ec5acb3d..1392d144e 100644 --- a/extensions/tags/js/forum/src/addTagFilter.js +++ b/extensions/tags/js/forum/src/addTagFilter.js @@ -20,6 +20,14 @@ export default function() { return original(); }); + extend(IndexPage.prototype, 'view', function(vdom) { + const tag = this.currentTag(); + + if (tag) { + vdom.attrs.className += ' IndexPage--tag'+tag.id(); + } + }); + // If currently viewing a tag, restyle the 'new discussion' button to use // the tag's color. extend(IndexPage.prototype, 'sidebarItems', function(items) { diff --git a/extensions/tags/src/Api/Serializer/TagSerializer.php b/extensions/tags/src/Api/Serializer/TagSerializer.php index 8979456b1..da61ad5e4 100644 --- a/extensions/tags/src/Api/Serializer/TagSerializer.php +++ b/extensions/tags/src/Api/Serializer/TagSerializer.php @@ -12,7 +12,7 @@ namespace Flarum\Tags\Api\Serializer; use Flarum\Api\Serializer\AbstractSerializer; -use Flarum\Api\Serializer\DiscussionSerializer; +use Flarum\Api\Serializer\DiscussionBasicSerializer; class TagSerializer extends AbstractSerializer { @@ -64,6 +64,6 @@ class TagSerializer extends AbstractSerializer */ protected function lastDiscussion($tag) { - return $this->hasOne($tag, DiscussionSerializer::class); + return $this->hasOne($tag, DiscussionBasicSerializer::class); } } diff --git a/extensions/tags/src/Listener/AddForumTagsRelationship.php b/extensions/tags/src/Listener/AddForumTagsRelationship.php index abcb4f91f..a7e7782cc 100755 --- a/extensions/tags/src/Listener/AddForumTagsRelationship.php +++ b/extensions/tags/src/Listener/AddForumTagsRelationship.php @@ -68,7 +68,10 @@ class AddForumTagsRelationship // doesn't actually have a tags relationship, we will manually load and // assign the tags data to it using an event listener. if ($event->isController(ShowForumController::class)) { - $event->data['tags'] = Tag::whereVisibleTo($event->actor)->withStateFor($event->actor)->with('lastDiscussion')->get(); + $event->data['tags'] = Tag::whereVisibleTo($event->actor) + ->withStateFor($event->actor) + ->with(['parent', 'lastDiscussion']) + ->get(); } }