[MTOS-dev] testing var for empty before using in mt:loop
Steve Ivy
steveivy at gmail.com
Thu May 1 17:37:57 PDT 2008
Thanks Beau! I would have trialed-and-errored it earlier but was at work...
On Thu, May 1, 2008 at 5:35 PM, Beau Smith <beau at sixapart.com> wrote:
> Steve_
>
> Here are two examples that will work if foo_loops is null or "" or 0....
>
> ------------
>
>
> <mt:if name="foo_loops">
> <mt:loop name="foo_loops">
> ...
> </mt:loop>
> <mt:else>
> zero-state message here
> </mt:if>
>
> ------------
>
>
> <mt:loop name="foo_loops">
> ...
> <mt:else>
> zero-state message here
> </mt:loop>
>
> ------------
>
>
> _beau
>
>
>
>
>
>
> On May 1, 2008, at 3:39 PM, Steve Ivy wrote:
>
> >
> >
> >
> > In this case, the code does a lookup of "all URIs for this Friend" and
> > assigns it to a param. It may be empty. In the tmpl, I want to show a
> > "No URIs" message instead of dropping into the loop if uris has no
> > entries.
> >
> > On Thu, May 1, 2008 at 3:34 PM, Timothy Appnel <tim at appnel.com> wrote:
> >
> > > Meaning null or '' or 0? Yes. Meaning an array refeence with zero
> > > elements? No. Not with mt:if in that position though I think the loop
> > > would never start if coo_loops was a reference to an empty array
> > > reference.
> > >
> > > Anyway, the mt:if statement and others follows the standard Perl
> > > evaluation of true and false values. Null, '' (blank string) or 0
> > > (zero) is false and everything else is true.
> > >
> > >
> > >
> > > <tim/>
> > >
> > > --
> > > Timothy Appnel
> > > Appnel Solutions
> > > http://appnel.com/
> > >
> > >
> >
> >
> >
> > --
> > Steve Ivy
> > http://redmonk.net // http://diso-project.org
> > This email is: [ ] bloggable [x] ask first [ ] private
> > _______________________________________________
> > MTOS-dev mailing list
> > MTOS-dev at sixapart.com
> > http://www.sixapart.com/mailman/listinfo/mtos-dev
> >
>
>
>
--
Steve Ivy
http://redmonk.net // http://diso-project.org
This email is: [ ] bloggable [x] ask first [ ] private
More information about the MTOS-dev
mailing list