ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

More than one category equals headaches

December 14, 2007 9:13am

Subscribe [3]
  • #1 / Dec 14, 2007 9:13am

    Simon Clayson

    38 posts

    DISCLAIMER: I’m editing a 1.4.2 installation. We can’t upgrade!

    I’m trying to do something simple. I think. I want to pull in selected entries from different categories and different weblogs. One of the weblog categories must display everything by default (weblog 1). The others via a Yes/No custom field. Here’s the code I want to work:

    {exp:weblog:entries category="1|2|3" orderby="date" sort="desc"  rdf="off" limit="8"}
            {if weblog_id =='1' OR custom_option == 'Yes'}
            <li><a href="http://{title_permalink={my_template_group}/page}">{title}</a></li>
            {/if}
    {/exp:weblog:entries}

    Without the conditional it works fine. but as soon as I introduce the conditional, I can only list 5 entries, when it should be 8. The others are disappearing.

    Am I missing anything glaringly obvious?

  • #2 / Dec 14, 2007 12:29pm

    Jamie Poitra

    409 posts

    Simon,

    Can I get you to add a space between the == and ‘1’ in your conditional and see if that works better?

    Jamie

  • #3 / Dec 14, 2007 12:36pm

    Simon Clayson

    38 posts

    Hi Jamie

    Tried that and I’ve tried double quotes eg == “1”. I’ve also tried != “2” for example.

    If I just have one category, it behaves, but not with two.

  • #4 / Dec 14, 2007 12:40pm

    Jamie Poitra

    409 posts

    Well that is plain weird.  The number of categories should have nothing to do, as far as I know, with how a conditional processes.

    Why is it you can’t upgrade?

    Jamie

  • #5 / Dec 14, 2007 12:45pm

    Jamie Poitra

    409 posts

    Simon,

    I think I know what your issue is.  And I think its a misunderstanding of how conditionals work.

    By doing this:

    {exp:weblog:entries category="1|2|3" orderby="date" sort="desc"  rdf="off" limit="8"}

    You limit the entries tag to 8 entries from categories 1, 2, and 3.  With the 8 most recent entries in those categories chosen first.

    By inserting a conditional you further limit the results of that.  So the tag may grab 8 entries.  But you conditional creates more constraints after the entries have been chosen.  So after those 8 have been whittled down to remove entries that don’t match the requirement of being in weblog 1 or having the custom_option value set to Yes you end up with 5 entries.

    That isn’t a bug.  That is the way conditionals work.

    Jamie

  • #6 / Dec 14, 2007 12:46pm

    Simon Clayson

    38 posts

    If it was up to me, I would. But. These things cost money. And I’m not paying!

    Struggling to think of a different way to do it. I’ve been round the houses already. Had trouble calling a conditional {category_id} with a categories variable pair tag.

  • #7 / Dec 14, 2007 12:49pm

    Derek Jones

    7561 posts

    Well how much time are you spending trying to work around this, Simon?  The solution is now a native feature in 1.6.1.  Updating is not so time consuming of an endeavor unless you have many hacks to keep track of.

  • #8 / Dec 14, 2007 12:51pm

    Simon Clayson

    38 posts

    I get what you mean but I’ve entries not showing that do meet the basic requirement of being in weblog_1 AND set to yes.

  • #9 / Dec 14, 2007 12:55pm

    Simon Clayson

    38 posts

    Hi Derek. Completely agree. But we’ve plenty of hacks and a custom module to boot. I’ve given an estimate to upgrade ages ago - and we’re still here!

  • #10 / Dec 14, 2007 12:55pm

    Derek Jones

    7561 posts

    I don’t think you’re quite getting Jamie’s explanation.  The tag is limiting the entries *first*, so what you are expecting to see may simply not be returned by the tag with the limit of 8.  Try this and perhaps it will click:

    {exp:weblog:entries category="1|2|3" orderby="date" sort="desc"  rdf="off" limit="8"}
    {count} - {title} - {if weblog_id =='1' OR custom_option == 'Yes'}(Conditional Met){/if}
    {/exp:weblog:entries}

    (Moved thread to Technical Support)

  • #11 / Dec 14, 2007 1:11pm

    Simon Clayson

    38 posts

    Excellent. I understand after a few plays around. I really don’t know what to do next though. And I’ve had a long day/week! Thanks for the fast responses once again.

  • #12 / Dec 14, 2007 1:28pm

    Derek Jones

    7561 posts

    You can always turn to the query module, which might be easiest for you if this is just generating a title list, and upgrading is in fact eliminated as a possibility.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases