2016-09-16 1 views
0

Frage:
Wie kann ich überprüfen, ob ein Wert mit 'A2', 'A7' und so weiter beginnt. Und wenn der Wert 'A2' ist, zeigen Sie nur alle Zeilen an, in denen '$aWoning.Woning_Bouwnr' mit 'A2' beginnt? Da ich neu bei Smarty bin, weiß ich jetzt wirklich nicht, was ich tun soll.Wie kann ich überprüfen, ob ein Wert mit "A2" in Smarty beginnt?

-Code/Html:

<table id="bouwnummers-table" class="table table-hover table-striped"> 
          <thead> 
          <tr> 
           <th>Bouwnummer</th> 
           <th>Woningtype</th> 
           <th>Woonopp.</th> 
           <th>Prijs vanaf</th> 
           <th>Status</th> 
          </tr> 
          </thead> 
          <tbody> 
          {foreach $aWoningen as $aWoning} 
           <tr> 
            <td>{$aWoning.Woning_Bouwnr}</td> 
            <td>{$aWoning.Projectwoning_Titel}</td> 
            <td>{$aWoning.Woning_WoonOpp} m&sup2;</td> 
            {*<td>{$aWoning.Woning_Adres|escape}</td>*} 
            <td> 
             {if $aWoning.Woning_Prijs!=0} 
              {if $aWoning.Verkocht!=1} 
               {$aWoning.Woning_Prijs|escape:"html"|lv_hele_euro} 
              {else} 
               Verkocht 
              {/if} 
             {else} 
              n.n.b. 
             {/if} 
            </td> 
            <td class="{if $aWoning.Verkocht==1}status-verkocht{elseif $aWoning.Optie==1}status-optie{else}status-beschikbaar{/if}"> 
             <i class="fa fa-square"></i> 
             {if $aWoning.Verkocht==1} 
              Verkocht 
             {elseif $aWoning.Optie==1} 
              In Optie 
             {else} 
              Beschikbaar 
             {/if} 
            </td> 
           </tr> 
          {/foreach} 
          </tbody> 
         </table> 

Antwort

0

Smarty "normalen" PHP-Funktionen verwenden können.

So:

{if $yourVarToCheck|strstr:"A2"} 
    //your code here 
{/if} 
+0

Das Fehlalarme zurück, wenn die Zeichenfolge so etwas wie "B1 Theme A2" ist – Borgtex

0

Wie in PHP, verwenden strpos

{if $yourVarToCheck|strpos:"A2"!== false} 
Verwandte Themen