Welcome, Guest. Please login or register.
Did you miss your activation email?


Login with username, password and session length

Search

 
Advanced search

8039 Posts in 1852 Topics- by 2099 Members - Latest Member: roi
Calendar Script CommunityCustomizationHacks and Mods (Moderators: scott, DanO, Marty)Testing for only a portion of a Custom Field value
Pages: [1]   Go Down
Print
Author Topic: Testing for only a portion of a Custom Field value  (Read 588 times)
0 Members and 1 Guest are viewing this topic.
TDPSS
Guest
« on: May 07, 2007, 06:38:00 PM »

I have a conditional statement were I need to test the string in "Display Text" value. Since this value is rather long, is there a way to test only the first 3 chars. Or use the "Option Value" instead, which is much shorter. Is this a Perl issue? If so - sorry, I should get a book and learn the syntax. I'd appreciate any help?
Thanks, Dennis
Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 227

Please don't PM me. Post in the open forum.


WWW
« Reply #1 on: May 07, 2007, 09:28:00 PM »

** I have a conditional statement were I need to test the string **

In what part of what template(s)??

** "Display Text" value... Or use the "Option Value" instead **

I assume the field you're testing is a select field?

It doesn't really matter though, the event details' data can all be retrieved the same way for an event on the calendar display templates, eg. $EVENT->{'details'}->{'Event_Field_ID_Here'}

The "Display Text" of the select field doesn't have anything to do with it.

JMO

Dan O.

------------------

Logged
TDPSS
Guest
« Reply #2 on: May 08, 2007, 01:24:00 AM »

Sorry, I'm still getting used to CalendarScripts terms. Anyway, I did solve the problem. I'm developing CalendarScript for a Community Center which rents out it's main hall, conference rooms, etc. For each entry, I wanted to show a Color Icon to indicate the entry status.
For example, Ok to stage event - GREEN, Event Requirements not met, - RED, . . etc.
Anyway, I added a custom field call "EventStatus" which contains a state-Id code range 1-9 which would indicate color plus an additional 20-30 char description.

Sample text in EventStatus is follows:

"<1> Agreement Signed, awaiting receipt of Fees and Deposits."
"<2> EventOk to Stage."
"<3> Event Pending Cancellation"
...

I was able to implement this scheme as follows:
default.html template

<%-- GRID STYLE DISPLAY --%>
<%FOREACH EVENT%>
----------------------------------------------
<%
if ($EVENT->{details}->{EventStatus} =~ /1/} { $icon="ICON-Yellow.gif";}
elsif ($EVENT->{details}->{EventStatus} =~ /2/} {$icon="ICON-Green.gif";}
elsif ($EVENT->{details}->{EventStatus} =~ /3/} {$icon="ICON-Red.gif";}
else {$icon="ICON-Grey.gif";}
%>

<img src="http://###.###.#.###:8080/<%=$icon%>" border=0 >  
----------------------------------------------

<%$i++;%>                     <SPAN CLASS="gridtext">
. . .

Note: I removed the local IP address for this posting.
I'm still testing, but this seems to work. The Icons are little 10x10 gifs and are displayed to the left of the time text. This works for all Grids and I haven't implemented yet for the Daily format. I'll post again, when I get that working. This is meta-code, so there might be some typos.

-Dennis

 

Logged
Pages: [1]   Go Up
Print
Jump to: