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

Problem mit Step in Section

 
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 -> Language: German
View previous topic :: View next topic  
Author Message
phuture
Smarty Rookie


Joined: 12 Jan 2005
Posts: 5

PostPosted: Thu Jan 13, 2005 8:45 am    Post subject: Problem mit Step in Section Reply with quote

Hallo!

Hab das folgende auch im Tips und Tricks gepostet, vielleicht ist es hier besser aufgehoben.

Ich habe folgenden Code:

Code:
table border=0 width="100%">
  {section name=parent loop=$aoShow step=$cols}
 
  <tr>
    {section name=td start=$smarty.section.parent.index loop=$smarty.section.parent.index+$cols}
    <td colspan="2" width="50%"><img src="{$smarty.const.EXTPATH_IMGPATH}{$aoShow[td]->FieldGet("pg_img")|default:"produkte/kalender/taschenkalender/taschenkalender.jpg"}"></td>     
    {/section}
  </tr>
 
 
  {/section}
 
 
</table>[quote]

Mein Problem ist, dass spätestens beim letzten Aufruf der inneren Section der Wert von step höher wird als die Gesamtzahl der im Array enthaltenen Werte wenn count($aShow) eine ungerade Zahl ist. Smarty ignoriert nicht wie erwartet diese Zeile sondern bricht das Parsen ab, sodass keine weiteren Anweisungen danach mehr ausgeführt werden (includes, etc....).

Hat jemand eine Idee oder einen Lösungsvorschlag?

Gruss,
PH  [/quote]
Back to top
View user's profile Send private message
T.
Smarty Regular


Joined: 22 Aug 2004
Posts: 69
Location: AT

PostPosted: Thu Jan 13, 2005 8:39 pm    Post subject: Reply with quote

ich verwende ein ähnliches script, so hab ichs aufgebaut:

Code:

<table style="width:100%">
{section name=count loop=$foto step=5}
<tr>
   {section name=i loop=$smarty.section.count.index+5 start=$smarty.section.count.index}
   {if $foto[i].F_ID ne ""}
      <td>
      <img src="{$foto[i].F_Name}" alt="{$foto[i].F_Description}" /></a>
      </td>
   {else}
      <td>&</td>   
   {/if}
   {/section}
</tr>
{/section}
</table>


bei mir funkt das eigentlich recht gut, wenn nix mehr vorhanden ist schreib ich halt ein leeres <td> rein...

mfg Thomas
_________________
Oppossom - Heavy rock from austria
Back to top
View user's profile Send private message Visit poster's website
phuture
Smarty Rookie


Joined: 12 Jan 2005
Posts: 5

PostPosted: Fri Jan 14, 2005 7:01 am    Post subject: Reply with quote

Hallo Thomas,

danke für den Tipp mit dem {if}!

Funktioniert leider bei mir nicht so, da ich ein Array of Objects habe. D.h. das Konstrukt müsste bei mir so aussehen:

Code:

   {if $aoShow[td]->FieldGet("id_prdgrp") != ""}


Leider funktioniert dies auch nicht so recht, da:

Code:
Fatal error: Call to a member function on a non-object in...


Eigentlich auch logisch, er versucht auf die Methode eines nicht funktionierendes Objektes zuzugreifen.

Hat eventuell jemand noch andere Vorschläge?

Gruss,
PH
Back to top
View user's profile Send private message
CaptainE
Smarty Rookie


Joined: 23 Dec 2004
Posts: 22

PostPosted: Fri Jan 14, 2005 11:45 am    Post subject: Reply with quote

Hi, also ich hab mir jetzt nicht den ganzen code angesehen aber wenn der da drauf zugreifen will und du noch nicht weißt ob da ein object drin ist oder nicht, dann prüf doch erst in einem if ab ob die variable ein object ist

also so:
[php:1:2930aebd4f]{if is_object($aoShow[td])}
{if $aoShow[td]->FieldGet("id_prdgrp") != ""}
// Aktionen
{/if}
{/if}
[/php:1:2930aebd4f]

Wenn der post nicht hilft, einfach ignrieren
Back to top
View user's profile Send private message
phuture
Smarty Rookie


Joined: 12 Jan 2005
Posts: 5

PostPosted: Fri Jan 14, 2005 3:35 pm    Post subject: Reply with quote

CaptainE wrote:
Hi, also ich hab mir jetzt nicht den ganzen code angesehen aber wenn der da drauf zugreifen will und du noch nicht weißt ob da ein object drin ist oder nicht, dann prüf doch erst in einem if ab ob die variable ein object ist

also so:
[php:1:1f975ba4fa]{if is_object($aoShow[td])}
{if $aoShow[td]->FieldGet("id_prdgrp") != ""}
// Aktionen
{/if}
{/if}
[/php:1:1f975ba4fa]

Wenn der post nicht hilft, einfach ignrieren


Hab ich auch schon gemacht, das Problem scheint ein ganz anderes zu sein. Das {if} an sich ist schon defakto sinnlos. Smarty bliebt stehen auch wenn ich dies mit is_object oder anderweitig das Objekt überprüfe.

Vielleich weiss noch jemand was dazu....

Trotzdem Danke für die Idee!

Gruss,
PH
Back to top
View user's profile Send private message
phuture
Smarty Rookie


Joined: 12 Jan 2005
Posts: 5

PostPosted: Mon Jan 17, 2005 9:55 am    Post subject: Reply with quote

Ich habe das Problem nun zwar nicht gelöst aber zumindest umgangen.
Ich vermute es ist sogar ein Bug.

Das Problem tritt nur auf wenn man auf Methoden zugreift, bei reinen Datenarrays ist dies nicht der Fall. Also setz ich mein (Template-)Array bereits im Code zusammen wie ich es im Template benötige.

Gruss,
PH
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 -> Language: German All times are GMT
Page 1 of 1

 
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