AW: [SMARTY] Help in <can't describe it> appreciated]
| From: | Joscha Feth | Date: | Sun, 23 Feb 2003 22:27:37 +0000 |
| Subject: | AW: [SMARTY] Help in <can't describe it> appreciated] | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-8140@lists.php.net to get a copy of this message | ||
Hi messju,
Thank you a lot - my "dead point" was including the script one more time if
another level shall follow, that is really a good trick!
Thanks!
Joscha
> -----Ursprüngliche Nachricht-----
> Von: messju mohr [mailto:messju@lammfellpuschen.de]
> Gesendet: Sonntag, 23. Februar 2003 08:06
> An: smarty-general@lists.php.net
> Betreff: Re: [SMARTY] Help in <can't describe it> appreciated]
>
>
> sorry, i cc'ed to the wrong list :(
>
> ----- Forwarded message from messju mohr
> <messju@lammfellpuschen.de> -----
>
> or, for an arbitrary depths of sets:
>
> php:
> <?php
>
> require('../site.php');
>
> /* copied from jason: */
> $d = array(
> 2 => array(
> 'enums' => array(6 => 'blue',5 =>
> 'yellow',7 =>'red')
> ,'name' => 'color'
> )
> ,11 => array(
> 'enums' => array(15 => 'polyester',13
> => 'cotton')
> ,'name' => 'material'
> )
> ,1 => array(
> 'enums' => array(9 =>
> 'S',8=>'M',11=>'L', 10=>'XL')
> ,'name' => 'size'
> )
> );
>
> $d_keys = array(11,1,2); /* or array_keys($d) if order was
> correct :) */
>
>
> $smarty->assign('d', $d);
> $smarty->assign('d_keys', $d_keys);
> $smarty->assign('i', 0);
> $smarty->assign('depth', sizeof($d_keys));
>
>
> $smarty->display('recurse.tpl');
>
> ?>
>
>
>
> recurse.tpl:
>
> {if ($i<$depth)}
> {assign var=d_key value=$d_keys.$i}
> <table border="1">
>
> {if ($i<($depth-1))}
> {* body of recursion *}
>
> <tr><th colspan="2">{$d.$d_key.name}</th></tr>
> {foreach from=$d.$d_key.enums item=v}
> <tr>
> <td>{$v}</td>
> <td>
> {math assign=i2 equation="i + 1" i=$i}
> {include file="recurse.tpl" i=$i2}
> </td>
> </tr>
> {/foreach}
>
> {else}
> {* last recursion *}
>
> <tr><th>{$d.$d_key.name}</th></tr>
> {foreach from=$d.$d_key.enums item=v}
> <tr>
> <td>{$v}</td>
> </tr>
> {/foreach}
>
> {/if}
> </table>
>
> {else}
> {* end of recursion *}
>
> {/if}
>
>
>
> have fun
> messju
>
> On Sat, Feb 22, 2003 at 09:53:16PM -0600, Jason Sweat wrote:
> > php:
> > $t = new Smarty;
> >
> > $d = array(
> > 2 => array(
> > 'enums' => array(6 => 'blue',5 => 'yellow',7
> > =>'red')
> > ,'name' => 'color'
> > )
> > ,11 => array(
> > 'enums' => array(15 => 'polyester',13 =>
> > 'cotton')
> > ,'name' => 'material'
> > )
> > ,1 => array(
> > 'enums' => array(9 =>
> > 'S',8=>'M',11=>'L', 10=>'XL')
> > ,'name' => 'size'
> > )
> > );
> > $t->assign(array(
> > 'mat' => $d[11]
> > ,'col' => $d[2]
> > ,'siz' => $d[1]
> > ));
> > $t->display('test.tpl');
> >
> > template:
> > <table border="1">
> > {foreach from=$mat.enums item=cur_mat key=key_mat name=mat}
> > {if $smarty.foreach.mat.first}
> > <tr><th colspan="2">{$mat.name}</th></tr>
> > {/if}
> > <tr valign="top"><td>{$key_mat} => {$cur_mat}</td>
> > <td><table border="1">
> > {foreach from=$siz.enums item=cur_siz key=key_siz name=siz}
> > {if $smarty.foreach.siz.first}
> > <tr><th colspan="2">{$siz.name}</th></tr>
> > {/if}
> > <tr valign="top"><td>{$key_siz} => {$cur_siz}</td>
> > <td><table border="1">
> > {foreach from=$col.enums item=cur_col key=key_col name=col}
> > {if $smarty.foreach.col.first}
> > <tr><th colspan="2">{$col.name}</th></tr>
> > {/if}
> > <tr valign="top"><td>{$key_col} => {$cur_col}
> > {/foreach}
> > </table>
> > </td></tr>
> > {/foreach}
> > </table>
> > </td></tr>
> > {/foreach}
> > </table>
> >
> > ----- Original Message -----
> > From: "Joscha Feth" <joscha@feth.com>
> > To: <smarty-general@lists.php.net>
> > Sent: Saturday, February 22, 2003 12:05 PM
> > Subject: [SMARTY] Help in <can't describe it> appreciated
> >
> >
> > > Please read here, I put together a small description of
> my problem - all
> > > thoughts, ideas, advises, better methods, etc.
> appreciated (I am nearly
> > > getting crazy with this thing)
> > >
> > > http://www.feth.com/uploads/case_study1.html
> > >
> > > Greets,
> > > Joscha
>
> ----- End forwarded message -----
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>