PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.smarty.general > Using arrays as input to plugins
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Using arrays as input to plugins

Réponse
 
LinkBack Outils de la discussion
Vieux 26/04/2006, 17h23   #1
Cody Caughlan
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Using arrays as input to plugins

Hello-

I have noticed some odd stuff going on with using associative arrays
and the "." syntax. When I am handing off data to a plugin, or any
other Smarty plugin (e.g. {include}), it doesnt handle using
associative arrays.

E.g.

$foobar = array('file' => 'foo.tpl');
$smarty->assign("foobar", $foobar);

---- foo.tpl ---

{include file=$foobar.file}

What happens is that it looks for a variable called "$foobar", doesnt
find it, so returns the empty string and then just appends
".file"...basically Smarty doesnt "dive into" the array, as it would
if I just did:

You are looking for {$foobar.file}

In my case I have written a plugin "dispText" and am trying to call it as such:

{dispText name="Name" value="$navItem.Name" label=$lblName
readOnly=$navItem.readOnly}

Where $navItem is an associative array I have previously assigned, and
those key names definitely exist. When my plugin executes it creates a
form input of type text and then in the value portion just display
".Name" because it cannot extract that value from the array $navItem
using the key as I have defined it.

So is there a way I can get it to read the array values WITHOUT doing
an {assign} first and pulling all of my values out. That would really
suck. I would think this is a core parser change and hence its not so
quick and easy.

Thanks
/Cody
  Réponse avec citation
Vieux 26/04/2006, 22h58   #2
Jeroen de Jong
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] Using arrays as input to plugins

See the manual:
http://smarty.php.net/manual/en/lang...tax.quotes.php


Jeroen

----- Original Message -----
From: "Cody Caughlan" <toolbag@gmail.com>
To: <smarty-general@lists.php.net>
Sent: Wednesday, April 26, 2006 6:23 PM
Subject: [SMARTY] Using arrays as input to plugins


Hello-

I have noticed some odd stuff going on with using associative arrays
and the "." syntax. When I am handing off data to a plugin, or any
other Smarty plugin (e.g. {include}), it doesnt handle using
associative arrays.

E.g.

$foobar = array('file' => 'foo.tpl');
$smarty->assign("foobar", $foobar);

---- foo.tpl ---

{include file=$foobar.file}

What happens is that it looks for a variable called "$foobar", doesnt
find it, so returns the empty string and then just appends
".file"...basically Smarty doesnt "dive into" the array, as it would
if I just did:

You are looking for {$foobar.file}

In my case I have written a plugin "dispText" and am trying to call it as
such:

{dispText name="Name" value="$navItem.Name" label=$lblName
readOnly=$navItem.readOnly}

Where $navItem is an associative array I have previously assigned, and
those key names definitely exist. When my plugin executes it creates a
form input of type text and then in the value portion just display
".Name" because it cannot extract that value from the array $navItem
using the key as I have defined it.

So is there a way I can get it to read the array values WITHOUT doing
an {assign} first and pulling all of my values out. That would really
suck. I would think this is a core parser change and hence its not so
quick and easy.

Thanks
/Cody

--
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
  Réponse avec citation
Vieux 27/04/2006, 14h47   #3
Mark Rogers
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] Using arrays as input to plugins

Cody Caughlan wrote:
> {include file=$foobar.file}
>

This should work exactly as you would expect it to. I think what you
actually have a problem with is:

{include file="$foobar.file"}

... which is a completely different thing, and is indeed interpreted as $foobar . '.file'.

Jeroen's comment to read the manual (http://smarty.php.net/manual/en/lang...tax.quotes.php) is valid if this is what you are trying to do, but really you should remove the quotes.


> {dispText name="Name" value="$navItem.Name" label=$lblName
> readOnly=$navItem.readOnly}
>


Likewise,
value="$navItem.Name"
is not the same as
value=$navItem.Name
but is the same as
value="`$navItem.Name`"

I'm not sure why a lot of PHP coders tend to put quotes around things
that don't need it (eg mysql_connect("$host", ...)) but it often causes
problems further down the line.

--
Mark Rogers
More Solutions Ltd :: 0845 45 89 555
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 17h28.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,08921 seconds with 11 queries