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

Display specific arrays

 
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
andrey613
Smarty n00b


Joined: 04 Sep 2015
Posts: 2

PostPosted: Fri Sep 04, 2015 11:30 am    Post subject: Display specific arrays Reply with quote

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
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Fri Sep 04, 2015 8:26 pm    Post subject: Reply with quote

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
View user's profile Send private message
andrey613
Smarty n00b


Joined: 04 Sep 2015
Posts: 2

PostPosted: Mon Sep 07, 2015 6:25 am    Post subject: Reply with quote

Nice, THX this is great and it is working perfect.
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
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