|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
andrey613 Smarty n00b
Joined: 04 Sep 2015 Posts: 2
|
Posted: Fri Sep 04, 2015 11:30 am Post subject: Display specific arrays |
|
|
I'm new to smarty and I want to display all the arrays that contains 'sezoniere' => null I have a loop
Code: | {foreach from=$servList item=_item name=servList}
<h6><a href="{$baseURL}{if !$smarty.foreach.servList.first}{$_item.post_name}{else}servicii{/if}/" title="{$_item.nume}">{$_item.nume}</a></h6>
{/foreach} |
Here is the array:
Code: | 'id' => string '1' (length=1)
'nume' => string 'Serviciul 1' (length=11)
'post_name' => string 'serviciul-1' (length=11)
'sezoniere' => string '1' (length=1) |
The second array in the loop:
Code: | 'id' => string '2' (length=1)
'nume' => string 'Serviciul 2' (length=11)
'post_name' => string 'serviciul-2' (length=11)
'sezoniere' => null |
How I can display in the loop above only the array's that have Code: | 'sezoniere' => null | ? |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Fri Sep 04, 2015 8:26 pm Post subject: |
|
|
Using the right syntax?
Code: | {foreach $servList as $_item}
{if $_item.sezoniere}{* do nothing *}{else}
<h6><a href="{$baseURL}{if $_item@first}servicii{else}{$_item.post_name}{/if}/" title="{$_item.nume}">{$_item.nume}</a></h6>{/if}
{/foreach} |
|
|
Back to top |
|
andrey613 Smarty n00b
Joined: 04 Sep 2015 Posts: 2
|
Posted: Mon Sep 07, 2015 6:25 am Post subject: |
|
|
Nice, THX this is great and it is working perfect. |
|
Back to top |
|
|
|
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
|