This question is answered. Helpful answers available: 0. Correct answers available: 1.


Permlink Replies: 9 - Pages: 1 - Last Post: 23 May 14, 01:31 Last Post By: JeffTucker
jimberry

Posts: 493
Registered: 30-Aug-2004
Can "fileiterator" be called in a custom template HTT ?
Posted: 19 May 14, 12:27
 
  Click to reply to this thread Reply
I am a little confused about the new(ish) custom htt templates.
Is there a tutorial on how to implement them?

I wanted a variation of the index.htt to produce just the index links to subfolders, with no surrounding elements like headings. This would be used in an iframe in sub-indexes and slide pages to enable simpler navigation to sibling folders (without having to navigate back up and then down again).

I was able to create an index.htt which produced the required page if included in a new skin, but the same code renamed as "navbar.htt" and inserted into the "Image directory" just produced a blank page, with nothing emanating from the "fileiterator" code.

Is there a scope conflict when trying to use "fileiterator" from the "Image directory" ?
JeffTucker

Posts: 8,337
Registered: 31-Jan-2006
Re: Can "fileiterator" be called in a custom template HTT ?
Posted: 19 May 14, 13:34   in response to: jimberry in response to: jimberry
Helpful
  Click to reply to this thread Reply
Haven't done any testing, but I think you're running into one of those little peculiarities that gives the fileiterator its "charm." Its scope is tied to the paging of index, index2, and so on. But in this case you want it to iterate through the entire directory. First, I'd try adding start=0, which causes the file iterator to ignore the "paging":
<ja:fileiterator start=0><ja:if exists="folder">Do something</ja:if></ja:fileiterator>
But you may end up having to do your own traversal of the directory in Beanshell code, something like this:
<%
List l = currentFolder.getChildren();
for (int i = 0; i < l.size(); i++) {
	AlbumObject ao = l.get(i);
	if(ao.isFolder()) {
		Do something;
	}
}
%>
jimberry

Posts: 493
Registered: 30-Aug-2004
Re: Can "fileiterator" be called in a custom template HTT ?
Posted: 19 May 14, 14:40   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
Thanks, Jeff :-)

Adding "start=0" seems to have done the trick.

As you might have guessed, this is to do with a request in the Chameleon forum about linking to sibling folders from within sub-indexes and slide pages. Making this page from a template in the "Image directory" means that it can be done without any changes to existing skins or adding a supporting new skin.
davidekholm

Posts: 3,969
Registered: 18-Oct-2002
Re: Can "fileiterator" be called in a custom template HTT ?
Posted: 19 May 14, 16:05   in response to: jimberry in response to: jimberry
Helpful
  Click to reply to this thread Reply
The default behavior of the fileiterator is to respect the paging, but adding start=x will certainly make it ignore the paging.
jimberry

Posts: 493
Registered: 30-Aug-2004
Re: Can "fileiterator" be called in a custom template HTT ?
Posted: 20 May 14, 05:43   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
Although I am happy with the "fix", just out of curiosity, how does "respect the paging " work? I might have expected it to iterate through the first page and then stop (which would have been OK in my example as there were only four subfolders), but it doesn't do any iterations at all.
davidekholm

Posts: 3,969
Registered: 18-Oct-2002
Re: Can "fileiterator" be called in a custom template HTT ?
Posted: 20 May 14, 21:37   in response to: jimberry in response to: jimberry
 
  Click to reply to this thread Reply
jimberry wrote:
Although I am happy with the "fix", just out of curiosity, how does "respect the paging " work? I might have expected it to iterate through the first page and then stop (which would have been OK in my example as there were only four subfolders), but it doesn't do any iterations at all.

I haven't checked the paging behavior when used on slide pages. When used on index pages, using no attributes at all should give a correct paging (i.e. iterate through the same images as the ja:rowiterator, ja:coliterator pairs do).

If you wish, then you can use relative references when using ja:fileiterator on slide pages, you can for instance write:
<ja:fileiterator start="-3" count="7" nodirs>
to iterate 7 images, starting 3 images before the current slide.
jimberry

Posts: 493
Registered: 30-Aug-2004
Re: Can "fileiterator" be called in a custom template HTT ?
Posted: 20 May 14, 23:37   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
It worked as stated on both index and slide pages.

However, it was when used in a custom page in the "Image directory" that it didn't iterate at all, even when rows were set at 0 or 500.

Using start="0" worked fine, however :-)
davidekholm

Posts: 3,969
Registered: 18-Oct-2002
Re: Can "fileiterator" be called in a custom template HTT ?
Posted: 21 May 14, 11:44   in response to: jimberry in response to: jimberry
 
  Click to reply to this thread Reply
jimberry wrote:
It worked as stated on both index and slide pages.

However, it was when used in a custom page in the "Image directory" that it didn't iterate at all, even when rows were set at 0 or 500.

Using start="0" worked fine, however :-)


Ok. Thanks for informing about that. I guess it doesn't know what paging to use when on a custom generated page. It also probably don't know what image is the "current" image. That's why you will need to explicitly set a "start" attribute.
jimberry

Posts: 493
Registered: 30-Aug-2004
Re: Can "fileiterator" be called in a custom template HTT ?
Posted: 23 May 14, 01:21   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
While specifically setting a value for the "start" attribute works for my usage (and thus my own particular issue is resolved), would it be inappropriate to suggest (since "custom" templates pages are now a feature of jAlbum) that when not specifically set (as in index and slide pages) the default value could be defaulted to zero?
JeffTucker

Posts: 8,337
Registered: 31-Jan-2006
Re: Can "fileiterator" be called in a custom template HTT ?
Posted: 23 May 14, 01:31   in response to: jimberry in response to: jimberry
 
  Click to reply to this thread Reply
jimberry wrote:
While specifically setting a value for the "start" attribute works for my usage (and thus my own particular issue is resolved), would it be inappropriate to suggest (since "custom" templates pages are now a feature of jAlbum) that when not specifically set (as in index and slide pages) the default value could be defaulted to zero?

That will break existing skins. If no "start" value is set, fileiterator iterates over the objects on the current page. If a "start" value is set, fileiterator iterates without regard to pagination. Skins have been written to rely on this behavior.
Legend
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums