This question is answered.


Permlink Replies: 7 - Pages: 1 - Last Post: 6 Jan 26, 22:46 Last Post By: JeffTucker Threads: [ Previous | Next ]
zif

Posts: 16
Registered: 8-Nov-2009
How to get the description of the folder one level up?
Posted: 6 Jan 26, 20:04
 
  Click to reply to this thread Reply
Hi, I use tiger skin and slightly adapt the slide.htt according to my needs. My album has a structure whith to level of folders. In the slide.htt I use the ${description} of the current album directory and also the ${albumDescription} of the entire album. If my slide is on the second folder level I would also like to integrate the description of the first folder level.

I tried really hard by searching in the forum and reading the tutorials. I also tried to get the breadcrumb sample script running. But unfortunately everything without success.

I don't want to be annoying with my very basic knowledge. But I would be very happy about any help in this matter.
JeffTucker

Posts: 8,041
Registered: 31-Jan-2006
Re: How to get the description of the folder one level up?
Posted: 6 Jan 26, 20:29   in response to: zif in response to: zif
Helpful
  Click to reply to this thread Reply
To do something different, depending upon which level of the album you're at, you can use the level variable. If you're on the top level of the album, level will be zero. At the first layer of folders, it will be one, and so on. So, the code might look like this:
<ja:if test="<%=level > 0%>">do something at every level below the top</ja:if>
Conversely:
<ja:if test="<%=level == 0%>">do something only at the top level</ja:if>
RobM

Posts: 3,948
Registered: 4-Aug-2006
Re: How to get the description of the folder one level up?
Posted: 6 Jan 26, 20:48   in response to: zif in response to: zif
 
  Click to reply to this thread Reply
You can use something like this (Groovy code) to get the comment of the folder above the subfolder
if(level >= 2 && currentObject.parent.isFolder()) currentObject.parent.parent.comment);
zif

Posts: 16
Registered: 8-Nov-2009
Re: How to get the description of the folder one level up?
Posted: 6 Jan 26, 21:36   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
@Jeff an Robb: Thanks for your very fast answers!

@Jeff: Your code is useful and brings me to some ideas. I will play around with it.
@Rob: This seems to be what I want. But sorry for my lack of knowledge. Do I have to put the code between <% and %> ? I always get an error message in this case. What am I doing wrong?
RobM

Posts: 3,948
Registered: 4-Aug-2006
Re: How to get the description of the folder one level up?
Posted: 6 Jan 26, 21:45   in response to: zif in response to: zif
Correct
  Click to reply to this thread Reply
zif wrote:
@Jeff an Robb: Thanks for your very fast answers!

@Jeff: Your code is useful and brings me to some ideas. I will play around with it.
@Rob: This seems to be what I want. But sorry for my lack of knowledge. Do I have to put the code between <% and %> ? I always get an error message in this case. What am I doing wrong?

Yes, it needs to go between those tags. The code worked when I entered it in slide.htt using Tiger skin
<%
if(level >= 2 && currentObject.parent.isFolder()) out.println(currentObject.parent.parent.comment);
%>

If it fails for you please attach your slide.htt template
zif

Posts: 16
Registered: 8-Nov-2009
Re: How to get the description of the folder one level up?
Posted: 6 Jan 26, 21:55   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
RobM wrote:
Yes, it needs to go between those tags. The code worked when I entered it in slide.htt using Tiger skin
<%
if(level >= 2 && currentObject.parent.isFolder()) out.println(currentObject.parent.parent.comment);
%>

It's like a miracle. Now it works. Exactly what I wanted. Thanks a lot!
RobM

Posts: 3,948
Registered: 4-Aug-2006
Re: How to get the description of the folder one level up?
Posted: 6 Jan 26, 22:01   in response to: zif in response to: zif
 
  Click to reply to this thread Reply
zif wrote:
RobM wrote:
Yes, it needs to go between those tags. The code worked when I entered it in slide.htt using Tiger skin
<%
if(level >= 2 && currentObject.parent.isFolder()) out.println(currentObject.parent.parent.comment);
%>

It's like a miracle. Now it works. Exactly what I wanted. Thanks a lot!

It's a kind of magic ;)
JeffTucker

Posts: 8,041
Registered: 31-Jan-2006
Re: How to get the description of the folder one level up?
Posted: 6 Jan 26, 22:46   in response to: zif in response to: zif
Helpful
  Click to reply to this thread Reply
zif wrote:
Do I have to put the code between <% and %> ?

That tells the engine that you're no longer using simple jAlbum scripting, and are, instead, writing Java/Groovy code. That's often simpler. For example:
<ja:if test="<%=level > 0%>">do something</ja:if>
 
Becomes:
 
<%
if(level > 0) {do something;}
%>
That frees you up to use more elaborate code, including more involved tests, like:
if(!someStringVariable.contains("mydog") {do something;}
This starts getting messy with jAlbum scripting.

It also makes nested if/else if/else tests way easier.

If you look at the source code in one of my skins, you'll see jAlbum scripting in index.htt and slide.htt (it there is one), but virtually all of the include files that are called from those templates live in the Java world.
Legend
Forum admins
Helpful Answer
Correct Answer

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