Closed stephenmeehanuk closed 3 weeks ago
Related to #2721.
@arthurperton I have an entries fieldtype with published and unpublished entries, and augmentation removes the unpublished entries. There seems to be no possible way to include them at the moment.
Would love to output them like Jason's solution. For example:
{{ features status:in="draft|published" }}
...
{{ /features }}
@mikemartin looks like you've commented on the wrong issue?
Is there any progress on this?
Hi, Is there any new updates or workaround concerning this issue?
I am using
{{ taxonomy:categories collection="projets|imagerie" }}
<option value="{{ url }}">{{ title }}</option>
{{ /taxonomy:categories }}
And it outputs Terms that are assigned only to draft/unpublished entries.
{{ taxonomy:categories collection="projets|imagerie" status:is="published" }}
does not work either.
Thanks
entries_count
als includes future posts. I don't think unpublished or future should be included anywhere, only when explicitly requesting it.
Anyone found a workaround?
A workaround I'm using is to check if the entry count is 0 (which only includes published entries), and if so, hide the taxonomy term from the listing.
For example:
{{ if {{collection:count from="collection" taxonomy:topics:any="{{slug}}"}} == 0}}
{{else}}
{{ title }} ({{ collection:count from="{{collection}}" taxonomy:topics:any="{{slug}}"}})
{{/if}}
This is still an issue. Our client unpublished some news and which let to empty news category pages. This solution is not unambiguous, since the taxonomy could be be unpublished:
{{ taxonomy:categories min_count="1" status:is="published" }}
But it would be really nice to have some kind of "clean" solution in the future.
I am running into this same issue -- taxonomy is showing entries with unpublished content.
{{ taxonomy:categories collection:is="blog" }}
<a href="#" id="slug" data-category="category-{{ slug }}" class="sidebar-nav-item {{ if active }}active{{/if}}">{{ title }}</a>
{{ /taxonomy:categories }}
{{ taxonomy:tags collection="articles" min_count="1" status:is="published" }}
The above code throws an error
Call to undefined method Statamic\Stache\Query\TermQueryBuilder::whereStatus()
Terms don't really have statuses, in the same way that entries do.
The {{ entries_count }}
won't be affected by any parameters on the taxonomy tag anyway, since that's not handled by the query.
Thanks for the clarification
But i tried {{ {taxonomy:tags collection="articles" min_count="1" title:contains="test"} | count }}
and it does affect the count, i tried other filters and the count gets affected too, only the "published" filter doesn't
Any help on that?
Oops! i think it's my bad
The title in title:contains="test"
refers to the tag title and not to the articles entries title
I get it now, sorry for that
Now my real question should be, how can i query the taxonomy:tags of collection="articles" where the articles entries are published only?
Any guidance on that? Thanks for your patience
For now, you can workaround it with a custom tag:
// app/Tags/TermEntriesCount.php
<?php
namespace App\Tags;
use Statamic\Facades\Entry;
use Statamic\Tags\Tags;
class TermEntriesCount extends Tags
{
/**
* The {{ term_entries_count }} tag.
*
* @return string|array
*/
public function index()
{
return Entry::query()
->where('collection', $this->params->get('collection'))
->whereTaxonomy($this->params->get('term'))
->whereStatus('published')
->count();
}
}
{{ taxonomy:tags }}
<a href="{{ url }}">{{ title }} ( {{ term_entries_count collection="articles" :term="id" }} )</a>
{{ /taxonomy:tags }}
Much respect sir! Thank you for your time
Bug Description
entries_count
includes published and unpublished entries.I'd like to see a way to filter this, in a similar way we can with
{{entries status:is="published"}}
How to Reproduce
Add a term to three entries, mark one entry as a draft.
entries_count
will display the number 3.Environment
Statamic version: 3.1.5 Pro
PHP version: 7.4.11
Install method (choose one):
statamic/statamic