If expression contains then

31 views
Skip to first unread message

David

unread,
Apr 24, 2008, 8:09:21 AM4/24/08
to SIMILE Widgets
Hi

Can you help?

I've been working with some data about resources. The Resource Owner
field has a lot of 'other' as the data in the field. (For some
reason!) I want to display a small graphic whenever this come up. (I
guess this in a 'lens')

To show 'Resource Owners' when the field is not blank, I've used:

<div ex:if-exists=".ResourceOwner">ResourceOwner:
<span ex:content=".ResourceOwner"></span>
</div>
(which works great!)

However, I'm trying to get to something like:

<div (ex:if .ResourceOwner = 'other' )><img src="image.png"><span
ex:content=".ResourceOwner"></span>
</div>

Any ideas what I could use to do this? I have searched around, and
suspect it is an expression [I found this:
ex:colorKey="contains(.speaks, 'Arabic')" over at
http://people.csail.mit.edu/dfhuynh/projects/factbook/factbook-people.html
-which is tantalisingly close, this returns 'true' or 'false']

Thanks!
David

David Huynh

unread,
Apr 24, 2008, 8:37:38 AM4/24/08
to simile-...@googlegroups.com
I am traveling through May 6th and I have intermittent access to my
email. Apologies if I don't get to your message in time.

- David Huynh

Axel Hecht

unread,
Apr 24, 2008, 12:10:19 PM4/24/08
to simile-...@googlegroups.com
I'd try something like

<img ex:if="not(.ResourceOwner)" src="..">

Axel

2008/4/24, David <da...@substance.coop>:

David

unread,
Apr 24, 2008, 12:49:16 PM4/24/08
to SIMILE Widgets
Thank for this it spurred me in the right direction.

I didn't realise 'ex:if=' was something that could be used.

Here is my solution:
[Problem: If 'ResourceOwner' field contains the text 'Other' then
display: Resource Owner: (an image) (field text i.e. Other).]

<div ex:if="contains(.ResourceOwner, 'Other')">
<span>ResourceOwner: <img src="image.jpg"/> <span
ex:content=".ResourceOwner"></span></span>
</div>
> > http://people.csail.mit.edu/dfhuynh/projects/factbook/factbook-people...

David Huynh

unread,
May 7, 2008, 4:34:47 PM5/7/08
to simile-...@googlegroups.com
David wrote:
> Thank for this it spurred me in the right direction.
>
> I didn't realise 'ex:if=' was something that could be used.
>
> Here is my solution:
> [Problem: If 'ResourceOwner' field contains the text 'Other' then
> display: Resource Owner: (an image) (field text i.e. Other).]
>
> <div ex:if="contains(.ResourceOwner, 'Other')">
> <span>ResourceOwner: <img src="image.jpg"/> <span
> ex:content=".ResourceOwner"></span></span>
> </div>
>
FYI, ex:if has an else clause, too

<div ex:if="exists(.foo)">
<div>this is the true clause</div>
<div>this is the false clause</div>
</div>

Alternatively, you can use ex:select

<div ex:select=".foo">
<div ex:case="abc">the .foo = abc case</div>
<div ex:case="def">the .foo = def case</div>
<div ex:case="ghi">the .foo = ghi case</div>
<div>any other cases, optional</div>
</div>

David

David

unread,
May 19, 2008, 5:19:20 AM5/19/08
to SIMILE Widgets
This is really useful.

Thanks for the input, the tool, all the work and effort etc.

All the best
David

Tully Hansen

unread,
Oct 25, 2015, 4:20:03 AM10/25/15
to SIMILE Widgets, da...@substance.coop
Forgive again my resurrecting an old post, but it seems the most relevant (and searchable) place to ask: should the modern (e.g. Exhibit 3.0) equivalent of this switching case work? I haven't been able to get it to do so.

<div data-ex-select=".type">
   <div data-ex-case="bots">the .type = bots case</div>
   <div data-ex-case="botally">the .type = botally case</div>
   <div data-ex-case="botmedia">the .type = botmedia case</div>
   <div data-ex-case="botmaterials">the .type = botmaterials case</div>
   <div>the catchall case</div>
</div>
<div data-ex-content=".type"></div>

As written, this seems to render only the second top-level div, even for those entries where .type should match a case.

Oddly, if I change the cases to check against an expression rather than a value, I get the catchall case rendered along with the second top-level div:

<div data-ex-select=".type">
   <div data-ex-case="contains(.type, 'bots')">the .type = bots case</div>
   <div data-ex-case="contains(.type, botally')">the .type = botally case</div>
   <div data-ex-case="contains(.type, 'botmedia')">the .type = botmedia case</div>
   <div data-ex-case="contains(.type, 'botmaterials')">the .type = botmaterials case</div>
   <div>the catchall case</div>
</div>
<div data-ex-content=".type"></div>

I know very little in the way of Javascript, and am not sure if user error or removed feature.

David Karger

unread,
Oct 25, 2015, 2:11:10 PM10/25/15
to simile-...@googlegroups.com
Tully, always more useful if you post a link to an exhibit demonstrating the problem, so others can look at it in practice.
--
You received this message because you are subscribed to the Google Groups "SIMILE Widgets" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simile-widget...@googlegroups.com.
To post to this group, send email to simile-...@googlegroups.com.
Visit this group at http://groups.google.com/group/simile-widgets.
For more options, visit https://groups.google.com/d/optout.

Tully Hansen

unread,
Oct 25, 2015, 10:13:35 PM10/25/15
to SIMILE Widgets, da...@substance.coop
Apologies David – see first column of Tabular layout at http://tullyhansen.github.io/botDB/botMEDIA/
Reply all
Reply to author
Forward
0 new messages