Last active
October 27, 2022 15:16
-
-
Save jacksleight/dd8e3b9a17d82a12ab0a3982770c1c3a to your computer and use it in GitHub Desktop.
Add entry count to taxonomy term listing
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
<?php | |
namespace App\Providers; | |
use App\Taxonomies\LocalizedTerm; | |
use Illuminate\Support\ServiceProvider; | |
use Statamic\Taxonomies\LocalizedTerm as StatamicLocalizedTerm; | |
class AppServiceProvider extends ServiceProvider | |
{ | |
public function boot() | |
{ | |
$this->app->bind(StatamicLocalizedTerm::class, LocalizedTerm::class); | |
} | |
} |
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
title: Category | |
sections: | |
main: | |
display: Main | |
fields: | |
- | |
handle: entries_count | |
field: | |
type: hidden | |
display: Entries | |
listable: true |
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
<?php | |
namespace App\Taxonomies; | |
use Statamic\Taxonomies\LocalizedTerm as StatamicLocalizedTerm; | |
class LocalizedTerm extends StatamicLocalizedTerm | |
{ | |
public function value($key) | |
{ | |
if ($key === 'entries_count') { | |
return $this->entriesCount(); | |
} | |
return parent::value($key); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment