Forums / Cotonti / Development / help with cotemplate

logical blocks

ez
#1 2011-12-28 22:10

Hi there,

I have problems with blocks... if MINIDIR_USERNAME is empty (i checked), then this div is shown anyway..
Am I doing something wrong here ???  cot version 0.6.20

 

            <!-- IF {MINIDIR_SHOWUSERNAME}=="1" AND {MINIDIR_USERNAME}!="" -->
                <div id="mb_admin_user">
                    {PHP.L.Username} : <b>{MINIDIR_USERNAME}</b>
                </div>
            <!-- ENDIF -->
 

 

==- I say: Keep it EZ -==
Alex300
#2 2011-12-29 06:58

Use spaces In logical operations.

Try this:

           <!-- IF {MINIDIR_SHOWUSERNAME} == "1" AND {MINIDIR_USERNAME} != "" -->
                <div id="mb_admin_user">
                    {PHP.L.Username} : <b>{MINIDIR_USERNAME}</b>
                </div>
            <!-- ENDIF -->
Есть миры, не здесь, там, где небеса горят, и моря засыпают, и реки дремлют; люди сделаны из дыма, а города – из песен. Где-то опасность, где-то несправедливость, даже где-то остыл чай. Идем Эйс, у нас много работы!...
...Sorry for my english...
Бесплатные расширения для Cotonti: https://lily-software.com/free-scripts/
ez
#3 2011-12-29 16:20

Sorry, it didn't work... :(

			<!-- IF {MINIDIR_SHOWUSERNAME} == "1" AND {MINIDIR_USERNAME} != "" -->
				<div id="mb_admin_user">
					{PHP.L.Username} : <b>{MINIDIR_USERNAME}</b>
				</div>
			<!-- ENDIF -->

With or without spaces... CoTemplate does not work the way i expect... and the vars i checked 200 times...

I am depending on this to work bigtime... but for now i find the cotemplate buggy in logical blocks... no

 

==- I say: Keep it EZ -==
This post was edited by ez (2011-12-29 16:35, 12 years ago)
pieter
#4 2011-12-29 18:01

If you try only one variable and lateron  the other one. At that moment you are sure the vars are OK.

Is AND not &&?

... can we help you ...
ez
#5 2011-12-29 19:09

@Pieter: I looked inside Cotemplate code... and NO its "AND"

To prove my point !!!


 myfiles5_494.png

With the existing template:

			<div id="mb_foldererror" style="display:none; padding:10px; margin:10px 0; color:red; border:red solid 1px"></div>
			--{MINIDIR_SHOWUSERNAME}-- ||{MINIDIR_USERNAME}||
			<!-- IF ({MINIDIR_SHOWUSERNAME} == "1" AND {MINIDIR_USERNAME} != "") -->
				<div id="mb_admin_user">
					{PHP.L.Username} : <b>{MINIDIR_USERNAME}</b>
				</div>
			<!-- ENDIF -->

I hate buggy crap shit... you see in example above that the labels produce a 1 and a name.. still my div does not get printed.. (The check labels go fine).

ALSO spaces between the elements do make a difference... thats shit to :(  (NOT happy)

 

==- I say: Keep it EZ -==
GHengeveld
#6 2011-12-29 19:43

Try this: 

<!-- IF {MINIDIR_SHOWUSERNAME} AND {MINIDIR_USERNAME} -->
ez
#7 2011-12-29 20:10

And the winner of today is Gert

			<!-- IF {MINIDIR_SHOWUSERNAME} == "1" AND {MINIDIR_USERNAME} -->
				<div id="mb_admin_user">
					{PHP.L.Username} : <b>{MINIDIR_USERNAME}</b>
				</div>
			<!-- ENDIF -->

STILL i find it very strange to not be able to do != ""

Thanks for the many responses... it was for Myfiles by the way smiley


ALSO this situation should be documented !!!!!

==- I say: Keep it EZ -==
GHengeveld
#8 2011-12-29 20:33

Maybe the username was never an empty string, but NULL ?

I try to use PHP Type Juggling when it makes things more simple. This is one such scenario, in this case it's converting to boolean.

This post was edited by GHengeveld (2011-12-29 20:39, 12 years ago)
ez
#9 2011-12-30 08:33

Sorry Gert, in this case NULL had nothing to do with it.

Look at example (post: 2011-12-29 19:09) there is clearly a string.

I still think that this is weird logic, and should be looked at... we should be able to test empty strings with a  [ != "" ] statement

==- I say: Keep it EZ -==
Trustmaster
#10 2011-12-30 10:08

I confirm this is a CoTemplate bug. If you try

<!-- IF {MINIDIR_USERNAME} != "" -->
    <div id="mb_admin_user">
        {PHP.L.Username} : <b>{MINIDIR_USERNAME}</b>
    </div>
<!-- ENDIF -->

this works but if you put there AND condition, then != stops working.

May the Source be with you!
ez
#11 2011-12-31 14:41

Is it in the Buglist allready... so that it get fixed ?

==- I say: Keep it EZ -==
Twiebie
#12 2011-12-31 15:34
ez
#13 2012-01-02 15:39

Hmmm.. I looked in the Genoa list..   (thats why i didnt see it)

Could this bug also be fixed in Genoa please...

==- I say: Keep it EZ -==
pieter
#14 2012-01-02 16:39