|
Replies:
10
-
Pages:
1
-
Last Post:
9 Aug 21, 14:26
Last Post By: JeffTucker
|
Threads:
[
Previous
|
Next
]
|
|
Posts:
8,010
Registered:
31-Jan-2006
|
|
|
|
Break out of iterator loop?
Posted:
8 Aug 21, 16:41
|
|
|
I may not end up needing this (still tinkering), but is there a way to break out of a file iterator loop? For example, I want to iterate over all the objects on the current page, but if I find the condition I'm looking for, there's no reason to continue the iteration. For example, checking to see if there are any thumbnail image comments on this page: <ja:fileiterator>
<ja:if exists="comment">
Found one!
break;
</ja:if>
</ja:fileiterator>
If it's not page-restricted, I would just use an ordinary ao.getChildren() "for" loop, where breaking out is simple.
|
|
|
Posts:
8,010
Registered:
31-Jan-2006
|
|
|
|
Re: Break out of iterator loop?
Posted:
8 Aug 21, 16:46
in response to: JeffTucker
|
|
|
|
BTW, one of the problems with getChildren() is that there doesn't seem to be a getChildren(currentPage) option. Not needed very often these days, since multiple index pages have bitten the dust in most skins, but....
|
|
|
Posts:
8,010
Registered:
31-Jan-2006
|
|
|
|
Re: Break out of iterator loop?
Posted:
8 Aug 21, 19:05
in response to: RobM
|
|
|
I suspected as much, but wanted to make sure I wasn't just forgetting something. These days, I'm usually doing my own tree traversals, and don't use the regular tags very often, so it's all a little rusty.
I did once solve the "children on this page" problem, but it's so convoluted, I hate to resort to it again:
https://jalbum.net/forum/thread.jspa?messageID=298359񈵷
Testing something like that might be enough to drive a developer mad.
|
|
|
Posts:
3,877
Registered:
4-Aug-2006
|
|
|
|
Re: Break out of iterator loop?
Posted:
8 Aug 21, 19:38
in response to: JeffTucker
|
|
|
I suspected as much, but wanted to make sure I wasn't just forgetting something. These days, I'm usually doing my own tree traversals, and don't use the regular tags very often, so it's all a little rusty.
I did once solve the "children on this page" problem, but it's so convoluted, I hate to resort to it again:
https://jalbum.net/forum/thread.jspa?messageID=298359񈵷
Testing something like that might be enough to drive a developer mad.
And files can be hidden now, not just folders!
|
|
|
Posts:
3,877
Registered:
4-Aug-2006
|
|
|
|
Re: Break out of iterator loop?
Posted:
8 Aug 21, 19:52
in response to: RobM
|
|
|
|
I don't know if it is possible to use the count option in the iterator, you would need to be able to access the internal counter and set it higher than the count value. I think all those variables are hidden though.
|
|
|
Posts:
8,010
Registered:
31-Jan-2006
|
|
|
|
Re: Break out of iterator loop?
Posted:
8 Aug 21, 19:55
in response to: RobM
|
|
|
And files can be hidden now, not just folders!
That's true just of "pages," isn't it? That includes web locations. I haven't addressed that in any of my skins, but none of them supports extra pages, anyway, and web locations are a separate kind of beast. Tough to think of the situation in which someone would want to have a web location object, but hide it - the core isn't going to "process" it in any fashion.
|
|
|
Posts:
8,010
Registered:
31-Jan-2006
|
|
|
|
Re: Break out of iterator loop?
Posted:
8 Aug 21, 21:57
in response to: JeffTucker
|
|
|
|
I'll leave this marked "unanswered" for now. But I realized that I was going to extraordinary lengths to address a fairly extreme fringe case that no normal user is ever likely to encounter. And even if someone did, the effects could be addressed with a single line of custom CSS with an !important stuck on the end of it, so it's really not worth the tsuris.
|
|
|
Posts:
3,804
Registered:
18-Oct-2002
|
|
|
|
Re: Break out of iterator loop?
Posted:
9 Aug 21, 14:13
in response to: JeffTucker
|
|
|
|
I don't remember that I've implemented any ja:break tag, so you'd have to manually iterate using getChildren(). I'm willing however to implement a ja:break as it's to be expected to exist whenever there are iterators around.
|
|
|
Posts:
8,010
Registered:
31-Jan-2006
|
|
|
|
Re: Break out of iterator loop?
Posted:
9 Aug 21, 14:17
in response to: davidekholm
|
|
|
|
Do it only if it's really, really easy. This is the first time in over 15 years that I've thought that I might need such a tag, and it turns out that I didn't need it anyway.
But yes, any looping structure probably should have a way to bail out.
|
|
|
Posts:
8,010
Registered:
31-Jan-2006
|
|
|
|
Re: Break out of iterator loop?
Posted:
9 Aug 21, 14:26
in response to: JeffTucker
|
|
|
|
What would probably be somewhat more useful is a method to let the skin do its own iteration over the objects on the current page. If the skin isn't doing multiple index pages, there's no problem - you just iterate over the children from predir.bsh. But things get messy when you are producing multiple index pages, and need to traverse only the piece of the tree that will be shown on the current page.
Probably not worth the effort, however. There are almost no remaining skins that support multiple index pages at a given level.
|
|
|
|
Legend
|
|
Forum admins
|
|
Helpful Answer
|
|
Correct Answer
|
|