Re: Fw: Insert Array
| From: | Monte Ohrt | Date: | Thu, 01 Nov 2001 16:49:21 +0000 |
| Subject: | Re: Fw: Insert Array | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-1786@lists.php.net to get a copy of this message | ||
This may be something you can contribute once the plugin architecture is
in place, but I don't think this is anything practical that we should
add to the Smarty core. Does anyone else have a use for this kind of
functionality? I'm thinking there are other ways to go about
accomplishing these needs given the current functionality of Smarty.
Roberto Berto wrote:
>
> I send to Monte and not to the list, sorry.
>
> > About your curiosity: I'm creating a form class to output in clientside
> and
> > internally serverside the validation. And some other features.
> >
> > The point about your question is:
> >
> > // You have an array inside your script.
> > $defs = array(
> > "users" => array(
> > "Roberto" => array(
> > "surname" => "berto",
> > "age" => 18
> > ),
> > "Andrei" => array(
> > ..
> > ),
> > "Monte" => array(
> > ...
> > )
> > ),
> > "products" => array(
> > "books" => array(
> > 0 => array("Booka","30.00"),
> > 1 => array("Bookb","60.00"),
> > 2 => array("Bookc","90.00"),
> > ),
> > "pens" ...
> > )
> > );
> >
> > And You want the script alter the surname of user Roberto, the age of
> Andrei
> > and the prize of booka
> >
> > So, you have a function called "alter" that change in one function without
> a
> > big code everything in your array $defs.
> >
> > So:
> >
> > {insert name="alter" users@Roberto@surname="Bertó"
> > users@Andrei@age="33"
> > produtos@books@0="29.90"}
> >
> > Imagine the function alter where you need only to:
> >
> > function insert_alter($attributes) {
> > if (is_array($attributes)) {
> > reset($attributes);
> > while (list($keys,$value) = each($attributes)) {
> > $this->elementsTable[$keys] = $value;
> > }
> > }
> > }
> >
> > And now, try do with string an no with array. Lol :-)
> >
> > Now I ask to you: this is the unique use to subtags like arrays?
> >
> >
> > I use this in my form class this form. Maybe I give it to public Smarty
> > addons.
> >
> >
> >
> > Atenciosamente,
> >
> >
> > Roberto Berto'
> > ----------------
> > roberto@berto.net
> >
> > eConsultor
> >
> > 0(XX)51 32270599 -> Horario preferencial: 13h - 20h
> > 0(XX)51 91169628 -> Em outros horarios
> >
> >
> > ----- Original Message -----
> > From: "Monte Ohrt" <monte@ispi.net>
> > To: "Roberto Berto" <roberto@berto.net>
> > Cc: <andrei@php.net>
> > Sent: Thursday, November 01, 2001 12:20 PM
> > Subject: Re: Insert Array
> >
> >
> > > Why wouldn't this work?
> > >
> > > {insert name=form defaultValue="Roberto" size="25"
> > > length="30"
> > > name="name"}
> > >
> > >
> > > function insert_form($args) {
> > > .....
> > > }
> > >
> > > And out of curiosity, why are you using an insert function to draw a
> > > form?
> > >
> > >
> > > Roberto Berto wrote:
> > > >
> > > > Take a look in this code.
> > > >
> > > > I alter the smarty, so now I can add Arrays into insert subtags like
> > > >
> > > > {insert name="form" attributes@defaultValue="Roberto"
> > attributes@size="25"
> > > > validation@lenght="30" attributes@name="name"}
> > > > {insert name="form" attributes@defaultValue=""
> > > > attributes@size="25"
> > > > validation@lenght="30" attributes@name="creditcard"
> > > > attributes@special@mastercard="1"
> > > > attributes@special@visa="1">
> > > >
> > > > So at
> > > > function insert_form($args) {
> > > > print $args[attributes][defaultValue];
> > > > // print Roberto
> > > > }
> > > >
> > > > I hope this will be usefull.
> > > >
> > > > Atenciosamente,
> > > >
> > > > Roberto Berto'
> > > > ----------------
> > > > roberto@berto.net
> > > >
> > > > eConsultor
> > > >
> > > > 0(XX)51 32270599 -> Horario preferencial: 13h - 20h
> > > > 0(XX)51 91169628 -> Em outros horarios
> > > >
> > >
> > ------------------------------------------------------------------------
> > > > Name: Smarty_Compile.class.php
> > > > Smarty_Compile.class.php Type: unspecified type
> > (application/octet-stream)
> > > > Encoding: quoted-printable
> > >
> > > --
> > > Monte Ohrt <monte@ispi.net>
> > > http://www.ispi.net/
> > >
> >
>
> ---
> You are currently subscribed to smarty as: monte@ispi.net
> To unsubscribe send a blank email to $subst('Email.Unsub')
> Visit Smarty's homepage at
> http://www.phpinsider.com/php/code/Smarty/
--
Monte Ohrt <monte@ispi.net>
http://www.ispi.net/