craft-cp-element-count
craft-cp-element-count copied to clipboard
Count shows all entries on a multisite setup.
Not sure if this is intended but when you have a channel that has his own entries per site the count badge shows the total result (of both sites).
...that has his own entries per site...
Do you mean that the channel is set up to not propagate entries?
This is a bug, I'll try to figure out how to pass the current site to the code that does the count, wasn't as straight forward as I thought. :)
I almost got it working:
$count = Entry::find()->section($slug)->limit(null)->status(['disabled', 'enabled'])->count(); should be extended with ->siteId(), but I couldn't manage to get the correct current site id:
$siteId = Craft::$app->getSites()->getCurrentSite(); // This always returned 1.
$count = Entry::find()->section($slug)->limit(null)->status(['disabled', 'enabled'])->siteId($siteId)->count();
We have installed the plugin few days ago and we are also using multi sites (using different domains for different sites and the channels are set up to NOT propagate entries). We were testing the plugin and for us it behaves like this:
- when switching the site by selecting the site from dropdown in Entries page of Control Panel
- main site: correct number
- second site: number from main site
- third site: number from main site
- when switching the site by logging in direcly in the other sites Control Panel (this is not how sites work but tried it for testing purposes)
- main site: correct number
- second site: correct number
- third site: correct number
This tells me the site uses current site as source for counting, which means it will always only look at the main site, no matter on what site you are currently.
We would also like if plugin would count each site separately. Thanks!
We also seem to be having a problem with the plugin on a multisite setup. We have three channels for sub sites, each with propagation disabled. However, none of the entries in the channels are counted.
