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

pusta sekcja...

 
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: Polish
View previous topic :: View next topic  
Author Message
web.admin.pl
Smarty n00b


Joined: 31 Jul 2008
Posts: 1

PostPosted: Thu Jul 31, 2008 8:40 pm    Post subject: pusta sekcja... Reply with quote

Witam was fachowcy... od niedawna zajmuje sie smarty i w sumie jestem zielony. Proszę was za tem o pomoc...

Mam plik tpl który wypisuje produkty z poszczególnej kategorii
Jednak niestety nie ma tam czegoś takiego, że jak kategoria jest pusta to pojawia się informacja, a na tym bardzo mi zależy.

Code:

{section name=prod_l loop=$produkty}
   {$produkty[prod_l].product_name}
{/section}


Chciałem się zapytać jaki warunek postawić który będzie prawdziwy gdy pętla jest pusta (tzn. nie będzie miała produktów) i gdzie go postawić.

Czy w ogóle jest coś takiego możliwego?

pozdrawaim
Back to top
View user's profile Send private message
fornve
Smarty Rookie


Joined: 25 Apr 2008
Posts: 29
Location: Sheffield, UK

PostPosted: Tue Aug 05, 2008 9:07 am    Post subject: Reply with quote

ten przyklad mozna zrobic latwiej przez petle foreach:

Code:

{foreach from=$produkty item=produkt name=produktloop}
    {$produkt.produkt_name}
{/foreach}


a przyklad z section:
Code:

{section name=prod_l loop=$produkty}
   {$produkty[prod_l].product_name}
{/section}


bedzie dzialal gdy np:
Code:

$produkty = array(
1 => array( 'product_name' => 'Produkt 1' ),
2 => array( 'product_name' => 'Produkt 2' ),
3 => array( 'product_name' => 'Produkt 3' )
 );
Back to top
View user's profile Send private message Visit poster's website
human
Smarty Rookie


Joined: 21 Oct 2005
Posts: 12
Location: Helldorado

PostPosted: Fri Sep 05, 2008 1:33 pm    Post subject: Re: pusta sekcja... Reply with quote

web.admin.pl wrote:
Jednak niestety nie ma tam czegoś takiego, że jak kategoria jest pusta to pojawia się informacja, a na tym bardzo mi zależy.


Proponuje:
Code:
{foreach from=$produkty item=produkt}
    {$produkt.product_name}
{foreachelse}
    Brak produktow
{/foreach}
Back to top
View user's profile Send private message Visit poster's website
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: Polish 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