multiple conditions in a single if - hash array?

Discuss news styles, css code, and other Coranto customizations in here...the possibilities are endless, so have at it!

Moderator: Spunkmeyer

multiple conditions in a single if - hash array?

Postby muttly » Mon Nov 21, 2005 5:42 pm

I am building a resource library and want the output to vary according to the type of file. When a file is a doc format rather than some form of embedded media, I want a single type of output

example
<If: Field: CustomField_Media_Format eq "mpg">
output link to new pg with object code for mpg

<If: Else: Field: CustomField_Media_Format eq "wmv">
output link to new pg with object code for wmv

<If: Else: Field: CustomField_Media_Format eq "doc txt xls, ppt, pdf ">
output direct download link to file
</If>


What is the proper syntax for saying if the Format = any of these choices

I think I want a hash array, but I don't understand how to delimit each format. Do I need a comma? a space? a pipe?

I know I can do a separate <If: Else> for each format, but I am hoping to avoid that.

As long as I am asking, if this isn't the purpose of a hash array, what does it get used for?
muttly
 
Posts: 178
Joined: Mon Jun 10, 2002 8:19 pm

Re: multiple conditions in a single if - hash array?

Postby Parahead » Mon Nov 21, 2005 8:01 pm

Maybe something like this?
Code: Select all
<PerlCode>
if($CustomField_Media_Format =~ /mpg/i) {
  $newshtml .= "output link to new pg with object code for mpg";
} elsif($CustomField_Media_Format =~ /wmv/i) {
  $newshtml .= "output link to new pg with object code for wmv";
} elsif($CustomField_Media_Format =~ /doc|txt|xls|ppt|pdf/i) {
  $newshtml .= "output direct download link to file";
} else {
  $newshtml .= "Unsuported extensions?";
}
</PerlCode>

Personally I would do a split of the URL based on a dot and fetch the extension that way instead of having a separate field for this, but that is just me...
Yes, I am still around...
www.parahead.com/coranto/
User avatar
Parahead
 
Posts: 4837
Joined: Fri Jan 12, 2007 8:54 pm
Location: Stockholm - Sweden


Return to Customization

Who is online

Users browsing this forum: No registered users and 2 guests

cron