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.

Stop "exp:weblog:entries"-Loop

January 21, 2009 3:49pm

Subscribe [3]
  • #1 / Jan 21, 2009 3:49pm

    tomtomtom

    46 posts

    Hi,

    I would like to make an “exp:weblog:entries”-loop to stop. I’m checking a condition and then I would like to tell it to stop. Is that possible?

    At this point I would like to mention again that I consider it a major drawback that I can’t use “real” variables in EE. That would make many things a lot easier.

    Thanks. Tom.

  • #2 / Jan 21, 2009 4:35pm

    Ingmar

    29245 posts

    No, there is no way to make it “stop” as such: no “break” instructions, as such, exist. That said, you can use conditionals and only display entries if/until/unless some values are met. Making sense, I hope? If you need “real” variables, there’s always PHP, which you can use in your EE templates as well.

  • #3 / Jan 21, 2009 5:09pm

    tomtomtom

    46 posts

    Yes, but as far as I can tell, there is no way to say “Only display the first match, if the condition is met more than once”.

  • #4 / Jan 21, 2009 5:13pm

    Ingmar

    29245 posts

    You might be able to use the {count} variable to that effect or, as I have said, a line or two of PHP. Would you like me to move this thread over to Howto do we can discuss possible approaches?

  • #5 / Jan 21, 2009 5:19pm

    Derek Jones

    7561 posts

    Can you take a step back and describe what you’re trying to accomplish?  Either the staff or a user more familiar with implementing custom solutions in ExpressionEngine may be able to make your life a bit easier. 😉  I can think of one way off the top of my head to do what you’re asking, but don’t want to recommend it without seeing the big picture.

  • #6 / Jan 21, 2009 5:20pm

    tomtomtom

    46 posts

    Thanks, I will:

    I am making an exp:query through categories which is necessary for technical reasons.

    Inside this Query I’m going through weblog-entries and inside that I’m using the {categories}-pair to check whether there is a match to my original category from the query.

    Only once I would like to show an image then.

    Unfortunately if there is another weblog entry which is assigned to this category it will bring up another image because it will go through the weblog:entries as often as there are entries.

  • #7 / Jan 21, 2009 5:35pm

    Derek Jones

    7561 posts

    It sounds like it might be best as a plugin using all PHP and direct queries.  Or your first query could provide the category filtering needed by the weblog entries tag, using a limit of 1, so that only one entry would ever be shown, and a conditional in your query tag to only display an image for the category you want, if the entry is in more than one category.

    My suggestion was originally going to be an extension hook, utilizing $EXT->end_script to halt the primary method’s execution, but that doesn’t seem like the best solution to your problem.  The other options are more elegant, and your performance is going to be better all around, and more tailored to your specific needs here if you go the plugin route.

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

ExpressionEngine News!

#eecms, #events, #releases