Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Re: [SMARTY] Problem with assign_by_ref
--- Jean-Sébastien Guay <jean_seb@videotron.ca> wrote:
> Hello,

Hi.

> I'm relatively new to Smarty, and I'm having trouble with
> assign_by_ref.
> Here's the situation.
>
> I'm passing a hash to a member function that looks like this :
>     public function presentResult( $result ) {
>         foreach ( $result as $key => $value ) {
>                 self::$smarty->assign_by_ref( $key, $value );
>         }
>
>         self::$smarty->display( 'index.tpl' );
>     }
> I was using assign() before, instead of assign_by_ref(), and it
> worked
> fine. But now I want to pass objects to Smarty as well as simple
> scalars, so I changed it to assign_by_ref() for all variables (since
> I
> don't modify any variables in templates, it doesn't really matter).
> Now,
> it seems as if none of my variables are making it to Smarty... If I
> look
> at the debug pop-up, all the variables show up as empty...
>
> Am I doing something wrong? I assume something like this should
> work...

Probably :)

That syntax looks rather like PHP5 to me. I'd say this: 1) don't pass
everything by reference -- it actually is slower to do so in the PHP
engine from everything I've read. 2) objects are automagically passed
by reference in PHP5. You don't have to do anything at all to get that
behaviour. 3) Smarty's code has not changed to reflect this change in
PHP5. If you really want to assign an object to smarty as by-val then
you must use the clone the object as you assign it. In other words, if
all you want to have is your objects passed by reference then leave
your original code the way it was. You are already getting that
behaviour in PHP5.

Of course, if you are using PHP4, that's a different matter entirely...

xo boots

>
> Thanks in advance,
>
> J-S

Report this thread to moderator Post Follow-up to this message
Old Post
Boots
04-30-05 02:00 AM


Re: [SMARTY] Problem with assign_by_ref
Hi Boots,

>That syntax looks rather like PHP5 to me.
>
It is.

>In other words, if
>all you want to have is your objects passed by reference then leave
>your original code the way it was. You are already getting that
>behaviour in PHP5.
>
>
Errr... ok. So I don't need assign_by_ref() at all? Then why does it say
I need it to get objects passed to Smarty here?
http://smarty.php.net/manual/en/advanced.features.php
--> Outdated documentation? That's bad...

Anyways, thanks for the info, I'll see if just using normal assign() works.

J-S

--
 ________________________________________
___
Jean-Sébastien Guay   jean_seb@videotron.ca
http://whitestar02.webhop.org/



--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.11.0 - Release Date: 2005/04/29

Report this thread to moderator Post Follow-up to this message
Old Post
Jean-Sébastien Guay
04-30-05 02:00 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP Smarty Templates archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 09:15 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.