Permlink Replies: 7 - Pages: 1 - Last Post: 16-Aug-2012 17:39 Last Post By: jGromit
jasonn

Posts: 1
Registered: 13-Jan-2007
<ja:if><ja:else> help please !!!
Posted: 13-Jan-2007 11:22
  Click to reply to this thread Reply
Hi. I am trying to use IPTC data to populate the Keywords metadata tag. I have managed to do this, but now need to add an IF statement, so that if the jpg doesn't contain any keywords, use some generic text. I can't get this to work!!!

Here is what I have put in the slide.htt file

<meta name="Keywords" content="<%= meta.get("Iptc.Keywords") %>" >

This works OK. But I can't figure out the if/else syntax :-(

do I need <ja:if>, of can I use <%= if(test)%> or what?

Also, the comparison must only be if the IPTC.Keywords text is blank, so I don't think I can use this compraison test <ja:if exists="meta">. I think the test would be

<meta name="Keywords" content="
<%=
IF (meta.get("Iptc.Keywords") = "")
{meta.get("Iptc.Keywords")}
ELSE
{"Default Keyword 1, Default Keyword 2, Default Keyword 3"}
%>
">

but this doesn't work.

I can't seem to get this ${meta.Iptc.Keywords} format to work either.

Please help!!

Thanks in advance,
Jason
jimberry

Posts: 533
Registered: 30-Aug-2004
Re: <ja:if><ja:else> help please !!!
Posted: 13-Jan-2007 12:31   in response to: jasonn in response to: jasonn
  Click to reply to this thread Reply
Iptc.Keywords should already be in the jAlbum variable $keywords so maybe

<ja:if exists="keywords">$keywords</ja:if>
<ja:else>
your fallback text
</ja:else>


might work
(I haven't tested this)
RoniM

Posts: 11
Registered: 17-Nov-2005
Re: <ja:if><ja:else> help please !!!
Posted: 13-Jan-2007 13:29   in response to: jasonn in response to: jasonn
  Click to reply to this thread Reply
Moved to more appropriate subforum...
airdrummer

Posts: 2
Registered: 4-Sep-2007
Re: <ja:if><ja:else> help please !!!
Posted: 16-Aug-2012 17:11   in response to: RoniM in response to: RoniM
  Click to reply to this thread Reply
and that subforum is????????

i 2 am interested in the ja:if/else syntax, particularly if/elseif/else or is that if/elsif???
jGromit

Posts: 7,709
Registered: 31-Jan-2006
Re: <ja:if><ja:else> help please !!!
Posted: 16-Aug-2012 17:28   in response to: airdrummer in response to: airdrummer
  Click to reply to this thread Reply
airdrummer wrote:
and that subforum is????????

This one. The thread was started elsewhere, and moved here.

i 2 am interested in the ja:if/else syntax, particularly if/elseif/else or is that if/elsif???

The jAlbum scripting language has only <ja:if> and <ja:else>. There is no else/if syntax. So all you can do is nest the tests, like this:
<ja:if test="${variable}" value="Choice one">
	Do something for first choice
</ja:if>
<ja:else>
	<ja:if test="${variable}" value="Choice two">
		Do something for second choice
	</ja:if>
	<ja:else>
		<ja:if test="${variable}" value="Choice three">
			Do something for third choice
		</ja:if>
	</ja:else>
</ja:else>
Of course, if your three choices are mutually exclusive, you can just do a series of "if" tests, without worrying about the "else" test:
<ja:if test="${variable}" value="Choice one">
	Do something for first choice
</ja:if>
<ja:if test="${variable}" value="Choice two">
	Do something for second choice
</ja:if>
<ja:if test="${variable}" value="Choice three">
	Do something for third choice
</ja:if>
jGromit

Posts: 7,709
Registered: 31-Jan-2006
Re: <ja:if><ja:else> help please !!!
Posted: 16-Aug-2012 17:29   in response to: jGromit in response to: jGromit
  Click to reply to this thread Reply
There is also a <ja:switch> tag available. See the example half-way down this page:

http://jalbum.net/en/developer/skins/tags
airdrummer

Posts: 2
Registered: 4-Sep-2007
Re: <ja:if><ja:else> help please !!!
Posted: 16-Aug-2012 17:35   in response to: jGromit in response to: jGromit
  Click to reply to this thread Reply
thanx 4 ur prompt response...nested it is:-)
jGromit

Posts: 7,709
Registered: 31-Jan-2006
Re: <ja:if><ja:else> help please !!!
Posted: 16-Aug-2012 17:39   in response to: airdrummer in response to: airdrummer
  Click to reply to this thread Reply
A lot of skin developers just drop back into Beanshell, which gives you straight Java. Then you can use more typical if/else constructions. Of course, then you have to do an out.print("stuff") to put lines into the HTML, so there are some tradeoffs.
Legend
Forum admins
Helpful Answer
Correct Answer

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