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


Permlink Replies: 6 - Pages: 1 - Last Post: 18 May 25, 17:28 Last Post By: davidekholm Threads: [ Previous | Next ]
dietrichhasse

Posts: 3
Registered: 17-May-2025
Change slide layout based on image name
Posted: 17 May 25, 10:40
 
  Click to reply to this thread Reply
I´d like to use different slide layouts within one gallery based on the naming convention of the image files. E.g. images including "_pan" in the file name should be shown in a different layout than others. I tried the following code (simplified) inside the slide.htt:

example 1:
<%
if ( imagePath.includes("_pan") ) {
out.println(imagePath + " is a panorama.");
}
%>

example 2:
<%
if ( "$imagePath".includes("_pan") ) {
out.println(imagePath + " is a panorama.");
}
%>

With both I get the same error message when I try to create the album:
reflection error: bsh.ReflectError: Method includes( java.lang.String ) not found in class'java.lang.String'

Please let me know, what I´m doing wrong! Thanks!
Dietrich
RobM

Posts: 4,017
Registered: 4-Aug-2006
Re: Change slide layout based on image name
Posted: 17 May 25, 11:12   in response to: dietrichhasse in response to: dietrichhasse
 
  Click to reply to this thread Reply
Switch to Groovy it is better than BeanShell, which has not been updated for over six years.
Use .contains() instead of .includes()

Plenty of scripting examples in the developer documentation.
RobM

Posts: 4,017
Registered: 4-Aug-2006
Re: Change slide layout based on image name
Posted: 17 May 25, 11:13   in response to: dietrichhasse in response to: dietrichhasse
 
  Click to reply to this thread Reply
Moving to skin and tool development as this is a question not a tip.
dietrichhasse

Posts: 3
Registered: 17-May-2025
Re: Change slide layout based on image name
Posted: 17 May 25, 17:31   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
I´m not a programmer and don´t have any experience with java. I´m using, whatever comes with JAlbum 5.1 and can´t tell whether it´s BeanShell or Groovy. I just need the snippet of code that allows me to run the if query properly.

.contains() gives me the same error.

Edited by: dietrichhasse on 17 May 2025, 17:59
RobM

Posts: 4,017
Registered: 4-Aug-2006
Re: Change slide layout based on image name
Posted: 17 May 25, 18:10   in response to: dietrichhasse in response to: dietrichhasse
 
  Click to reply to this thread Reply
Are you really using jAlbum 5.1?

Anyway, you could just use
if(imagePath.indexOf("_pan") != -1) {


Edited by: RobM on 17 May 2025, 17:13
jAlbum 5.1 does not support Groovy.
dietrichhasse

Posts: 3
Registered: 17-May-2025
Re: Change slide layout based on image name
Posted: 18 May 25, 16:53   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
brilliant, thanks!
davidekholm

Posts: 3,693
Registered: 18-Oct-2002
Re: Change slide layout based on image name
Posted: 18 May 25, 17:27   in response to: dietrichhasse in response to: dietrichhasse
 
  Click to reply to this thread Reply
Using .contains should work as well. Here's the String API documentation
Legend
Forum admins
Helpful Answer
Correct Answer

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