Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

White page on "if $Bestellung->kBestellung > 0&am
Goto page 1, 2  Next
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
albossum
Smarty Rookie


Joined: 04 Mar 2015
Posts: 8

PostPosted: Wed Mar 04, 2015 6:37 pm    Post subject: White page on "if $Bestellung->kBestellung > 0&am Reply with quote

Hi@all Smile

Iīve a problem with this code in case of $Bestellung->kBestellung is not set or 0, if $Bestellung->kBestellung is 1 or greater, then itīs okay. Otherwise i get a white page... I canīt find out the reason...

Code:
{if $Bestellung->kBestellung|@intval > 0}
...
{/if}


Thanks for your help!

cheers

rene
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Wed Mar 04, 2015 7:42 pm    Post subject: Reply with quote

If "$Bestellung->kBestellung|@intval" can't go below zero, you can write just that without any comparison.
And if that is a number, you don't need to waste CPU time applying @intval.
Back to top
View user's profile Send private message
albossum
Smarty Rookie


Joined: 04 Mar 2015
Posts: 8

PostPosted: Wed Mar 04, 2015 8:10 pm    Post subject: Reply with quote

You're right... This was a try before my post here, but it still doesn't work, with or without @intval... I can't figure out, whats the problem is...
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Thu Mar 05, 2015 12:03 am    Post subject: Reply with quote

Then enable all php error messages and enable display_errors.
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Fri Mar 06, 2015 1:56 am    Post subject: Reply with quote

If object or its property may not exist you should check it with isset()

Code:
{if isset($Bestellung->kBestellung) && $Bestellung->kBestellung|intval > 0}
...
{/if}


AnrDaemon wrote:
And if that is a number, you don't need to waste CPU time applying @intval.

The use of @ at modifier has nothing to do with error suppression. Smarty2 used it to run modifiers on arrays. In Smarty3 this is a noop.
Back to top
View user's profile Send private message
albossum
Smarty Rookie


Joined: 04 Mar 2015
Posts: 8

PostPosted: Fri Mar 06, 2015 10:02 am    Post subject: Reply with quote

Hm... I tried this, but it's still the same...
Btw. $Bestellung->kBestellung is set to 0... If it's set to 1 it works, no white page...

Code:
{if isset($Bestellung->kBestellung)}
...
{/if}
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Fri Mar 06, 2015 1:33 pm    Post subject: Reply with quote

isset($Bestellung->kBestellung) alone does only check if the object and kBestellung property does exist. you template still may fail if kBestellung == 0.

Try this
Code:
{if isset($Bestellung->kBestellung) && $Bestellung->kBestellungl > 0}
...
{/if}
Back to top
View user's profile Send private message
albossum
Smarty Rookie


Joined: 04 Mar 2015
Posts: 8

PostPosted: Fri Mar 06, 2015 8:07 pm    Post subject: Reply with quote

this doesn't work, too..

i still get the white page if $Bestellung->kBestellung is 0 or negative, if itīs 1 or greater, it works... I'm stumped...

this are the notices and warnings:
Quote:
Warning: Creating default object from empty value in /var/www/vhosts/zzz.com/httpdocs/includes/plugins/netzdingeDE_google_codes/version/104/frontend/classes/class.start.php on line 42
Notice: Undefined variable: cMetaTitle in /var/www/vhosts/zzz.com/httpdocs/includes/letzterInclude.php on line 130
Notice: Undefined variable: cMetaDescription in /var/www/vhosts/zzz.com/httpdocs/includes/letzterInclude.php on line 132
Notice: Undefined variable: cMetaKeywords in /var/www/vhosts/zzz.com/httpdocs/includes/letzterInclude.php on line 134
Notice: Undefined index: sidebox_categories_use_subcat_navi in /var/www/vhosts/zzz.com/httpdocs/templates/JTL-Shop3-Tiny-319/php/functions.php on line 204
Notice: Trying to get property of non-object in /var/www/vhosts/zzz.com/httpdocs/includes/tools.Global.php on line 7192
Notice: Trying to get property of non-object in /var/www/vhosts/zzz.com/httpdocs/includes/tools.Global.php on line 7197
Notice: Trying to get property of non-object in /var/www/vhosts/zzz.com/httpdocs/includes/tools.Global.php on line 7197
Notice: Undefined offset: 1 in /var/www/vhosts/zzz.com/httpdocs/includes/plugins/kk_mega_menu/version/108/licence/class.PluginLicence.php on line 24
Notice: A session had already been started - ignoring session_start() in /var/www/vhosts/zzz.com/httpdocs/includes/plugins/kk_mega_menu/version/108/frontend/99_mega_menu.php on line 12
Warning: Creating default object from empty value in /var/www/vhosts/zzz.com/httpdocs/includes/plugins/agws_piwik/version/308/frontend/agws_piwik_integration.php on line 0
Warning: Creating default object from empty value in /var/www/vhosts/zzz.com/httpdocs/includes/plugins/netzdingeDE_google_codes/version/104/frontend/classes/class.start.php on line 42


But there is no reference to the file (remarketing.tpl), the "isset($Bestellung->kBestellung) && $Bestellung->kBestellung > 0" statement is in.
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Fri Mar 06, 2015 10:53 pm    Post subject: Reply with quote

Are you sure that templates get recompiled after modification?
Is $smarty->compile_check == true ? which is the default setting.

You could try to clear the template_c and cache folder manually.

If you still get the error I suspect that the problem is not the {if} but somewhere else.

Does it run if you remove the {if} ... {/if} section?
Back to top
View user's profile Send private message
albossum
Smarty Rookie


Joined: 04 Mar 2015
Posts: 8

PostPosted: Sat Mar 07, 2015 12:13 am    Post subject: Reply with quote

As i said, ist runs, except the value is 0 or lower...
I found out, that it even runs when I change the if statement to $Bestellung->kBestellung == 0 instead of > 0

May it be, that just the equation causes this problem?
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Sat Mar 07, 2015 4:35 am    Post subject: Reply with quote

Just in case you copied and pasted my code: I had a typo.
Quote:
$Bestellung->kBestellungl > 0


Must be
Quote:
$Bestellung->kBestellung > 0
Back to top
View user's profile Send private message
albossum
Smarty Rookie


Joined: 04 Mar 2015
Posts: 8

PostPosted: Sat Mar 07, 2015 8:52 am    Post subject: Reply with quote

Thanks for that hint, no I didn't copy... Wink

It's really a strange thing...
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Sat Mar 07, 2015 12:06 pm    Post subject: Reply with quote

Which Smarty version do you use?

Set $smarty->debugging = true;

Check with it the assigned values.
Back to top
View user's profile Send private message
albossum
Smarty Rookie


Joined: 04 Mar 2015
Posts: 8

PostPosted: Sat Mar 07, 2015 12:42 pm    Post subject: Reply with quote

Thanks!

Version is 2.6.26
Because of the white page - i think- there is no debugging console with $smarty->debugging = true;

with $Bestellung->kBestellung = 1, the console shows that $Bestellung->kBestellung == 1 Wink

when I change the statement to "$Bestellung->kBestellung == 0" it all works fine, but i need it to "$Bestellung->kBestellung > 0" an this does not work

I post the complete "if":
Code:
...
{elseif $nSeitenTyp == 33 && isset($Bestellung->kBestellung) && $Bestellung->kBestellung > 0}
            {assign var="setValue" value=$oPlugin_netzdingeDE_google_codes->oPluginEinstellungAssoc_arr.cEcommTotalValue}
               {assign var="cArtNrString" value=""}
                {foreach name=AktuellerArtikel from=$Bestellung->Positionen item=AktuellerArtikel}
                    {if $AktuellerArtikel->cArtNr != ''}
                        {if $smarty.foreach.AktuellerArtikel.iteration > 1}
                            {assign var="cArtNrString" value="$cArtNrString,"}
                        {/if}
                       {assign var="cArtNrString" value=$cArtNrString|cat:'"'|cat:$AktuellerArtikel->cArtNr|cat:'"'}
                    {/if}
                {/foreach}
               {assign var="ecomm_prodid" value="[$cArtNrString]"}
               {assign var="ecomm_totalvalue" value=$Bestellung->$setValue}
            {/if}


remember this is working:
Code:
{elseif $nSeitenTyp == 33 && isset($Bestellung->kBestellung) && $Bestellung->kBestellung == 0}
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Sat Mar 07, 2015 3:54 pm    Post subject: Reply with quote

Ohh, Smarty 2 is outdated on no longer supported.

It's support of objects is very limited.
This workaround could work
Code:
{assign name='foo' value=$Bestellung->kBestellung}
{if $foo > 0}
....


Currently we have already Smarty 3.1.21 .

It has very good support for objects besides all sort of other features.


I should have ask the version question much earlier,
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP