Hi,
I released version 1.7 of Entries Number plugin.
In this plugin a new parameter - required_field - was implemented. It is an optional parameter which allows you to specify which custom field(s) should not be empty. Pipe character is supported; “not” operator is not supported.
E.g. if we have required_field=”custom_field1|custom_field2”, then only those entries will be counted which have at least one of these fields not empty.
Hi,
There are situations when something (say, A) should be outputted if in certain weblog or category there are certain number of entries but inside A also something should be outputted (say, B) if in certain other weblog or category there are certain number of entries. Unfortunately, EE plugins cannot be nested, that is, the code as this would not work:
{exp:entries_number category="6" weblog="not weblog1|weblog4" site="1"}
{if entries_number==0}
Some code
{exp:entries_number category="9" weblog="weblog5|weblog8" site="1"}
{if entries_number>0}
Some code
{/if}
{/exp:entries_number}
Some code
{/if}
{/exp:entries_number}
In order to be able to write this kind of code I released a clone of Entries Number plugin - Entries Number2. Its code is exactly the same as that of original plugin, except that the tag name is now {exp:entries_number2} and the variable is {entries_number2}.
Having installed both Entries Number and its clone Entries Number2 you can write the code as this:
{exp:entries_number category="6" weblog="not weblog1|weblog4" site="1"}
{if entries_number==0}
Some code
{exp:entries_number2 category="9" weblog="weblog5|weblog8" site="1"}
{if entries_number2>0}
Some code
{/if}
{/exp:entries_number2}
Some code
{/if}
{/exp:entries_number}
and it will work correctly.
Grab the file of Entries Number2 using the link in the first post in thread.
I’m a little confused as to what this plugin is for (could be the lack of sleep… ;)
Here’s what I’m trying to do, would this plugin allow to output something like that?
<ul>
<li><a href="#">category (count)</a></li>
<li><a href="#">category (count)</a>
<ul>
<li><a href="#">sub-category (count)</a></li>
<li><a href="#">sub-category (count)</a></li>
</ul>
</li>
<li><a href="#">category (count)</a></li>
</ul>
Thanks!
I don’t have code yet, I”m trying to figure out the best way to do that. The native EE tag for nested categories is not flexible at all, so I know I need to figure out another way, I”m looking at the easiest way to have nested categories + entries count for each category, in relation to a specific weblog, but for now, haven’t implemented any code. Thanks!
Hi,
If you can specify weblog then it seems that what you need can be achieved using exp:weblog:categories tag together with Entries Number plugin:
{exp:weblog:categories weblog="my_weblog" parse="inward" style="nested"}
{category_name},{exp:entries_number weblog="my_weblog" category="{category_id}"}{entries_number} entries{/exp:entries_number}
{/exp:weblog:categories}
If it is not possible to specify weblog then it depends on how complicated your categories are.
If you have only parent categories and subcategories, then perhaps, you could use Child Categories plugin together with Entries Number plugin; if you have subcategories which in their turn have subcategories, then perhaps, you could use Recursive Subcategories plugin together with Entries Number plugin.
Hi, If you can specify weblog then it seems that what you need can be achieved using exp:weblog:categories tag together with Entries Number plugin:If it is not possible to specify weblog then it depends on how complicated your categories are. If you have only parent categories and subcategories, then perhaps, you could use Child Categories plugin together with Entries Number plugin; if you have subcategories which in their turn have subcategories, then perhaps, you could use Recursive Subcategories plugin together with Entries Number plugin.{exp:weblog:categories weblog="my_weblog" parse="inward" style="nested"} {category_name},{exp:entries_number weblog="my_weblog" category="{category_id}"}{entries_number} entries{/exp:entries_number} {/exp:weblog:categories}
I still have to do some more testing, but so far it seems to be working very well. Thanks!!!
Hi Laisvunas,
The required_field could work for what I need, however it isn’t working. Here’s my code:
{exp:entries_number weblog="weblog1" category="24&56;" status="not closed" show_expired="no" required_field="extrainfo"}{entries_number} ads{/exp:entries_number}
I have 3 entries that would appear, I have removed content from the “extrainfo” field from one of the entries and it still counts all three entries even though only 2 of them have content in the extrainfo field.
Am I doing something wrong?
Thanks, Ryan
ok. I’ve upgraded and got the required_field parameter to work.
I’ve noticed that my queries shoot up to from 50 to 260 queries when I implement the required_field once on my page. Is this a bug? If I use the plugin 4 times on my page I get over 1000 queries taking place.
The number of queries seem to be relative to the number of entries being counted. for example, if I have 100 entries I’ll have 100 queries plus the standard EE queries for a template.
Ryan
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.