For lvthunder and smarty's expert. If with == not work

rob2

Joined: 2005-08-07
Posts: 40
Posted: Fri, 2005-08-26 12:50

How function smarty on Gallery2
How function the if with an equality ==?
------------------
this is ok
{if A==A}
.....
{/if}
-------------------
but if I write so (is only a test where 1st and 2nd are identical):

{if ( {g->url params=$link.params} ) == ( {g->url params=$link.params} ) }
....
{/if}
smarty not work (got error)

I want to confront this code:
{g->url params=$link.params}

with this
{g->url arg1="view=slideshowapplet.SlideshowApplet" arg2="itemId=`$theme.item.id`"}

How I can write the code?

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Fri, 2005-08-26 14:32

you cannot use {anything} when already inside {if}
how about {if $link.params == $link.params} ?
if the parameters are the same they should produce the same g->url..

 
lvthunder

Joined: 2003-09-12
Posts: 808
Posted: Fri, 2005-08-26 16:27

Maybe I'm confused (which at times isn't hard) but I don't understand what you are trying to do? Why would you want to write an if statement that will always be true?

 
rob2

Joined: 2005-08-07
Posts: 40
Posted: Sat, 2005-08-27 11:42
lvthunder wrote:
Maybe I'm confused (which at times isn't hard) but I don't understand what you are trying to do? Why would you want to write an if statement that will always be true?

This is only a test in order to control why Smarty got error when I
use the if.
Smarty so is ok work
{if A==A}
.....
{/if}
-------------------
but if I use this for test not work
{if ( {g->url params=$link.params} ) == ( {g->url params=$link.params} ) }
....
{/if}

although the 2 values are equal

The real comparison that I must make is within a cycle and must verify the point where the link (or parameters) of this:
{g->url params=$link.params}

is equal at link (or parameter) of this:
{g->url arg1="view=slideshowapplet.SlideshowApplet" arg2="itemId=`$theme.item.id`"}

The code that I have write is this
{if
({g->url params=$link.params})
==
{g->url arg1="view=slideshowapplet.SlideshowApplet" arg2="itemId=`$theme.item.id`"}

......
{/if}

but I have error so I have tested that code above;
and I have understand that this isn't the corrected form to write the code.

I think that I must compare not all the link but only the parameters
, but how?
some similar this:

($link.params) == (arg1="view=slideshowapplet.SlideshowApplet" arg2="itemId=`$theme.item.id`")

or this
($link.params) == ("view=slideshowapplet.SlideshowApplet" "itemId=`$theme.item.id`")

or this
($link.params) == (slideshowapplet.SlideshowApplet `$theme.item.id`)

any idea???

thanks