I’m trying to grab the count of a particular category, so if the category has more than 4 posts, I want posts from only that category to display…if it has less than 4 posts, I want to show the 4 recent posts from ALL categories.
But the logic of my code combined with the parse order is not liking my switch classes…other than the left/right switch, everything else works.
{exp:query sql="SELECT count(cat_id) AS 'cat_count' FROM exp_category_posts WHERE cat_id='6'"}
{if cat_count < 4}
{exp:weblog:entries weblog="work" limit="4" exclude="memberdata|trackbacks"}
<dl class="{switch="left|right"}">
<dt>{title}</dt>
<dd><span class="main_img"><a href="http://{title_permalink=work}" class="fp">{work_imagemain}</a></span></dd>
</dl>
{/exp:weblog:entries}
{/if}
{if cat_count >== 4}
{exp:weblog:entries weblog="work" category="6" limit="4" exclude="memberdata|trackbacks"}
<dl class="{switch="left|right"}">
<dt>{title}</dt>
<dd><span class="main_img"><a href="http://{title_permalink=work}" class="fp">{work_imagemain}</a></span></dd>
</dl>
{/exp:weblog:entries}
{/if}
{/exp:query}Am I going to have to do another query within the exp:weblog:entries tag just to get the current count and make the switch manually?
Edited to add:
EE: 1.6.4
Build: 20080808
URL: http://m2.westnethost.com - “featured projects” on the index page
(this is my test site, the actual site is not live yet and can only be accessed by editing hosts files)