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

Getting smarty vars from php code
Goto page 1, 2  Next
 
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 -> Feature Requests
View previous topic :: View next topic  
Author Message
muppie
Smarty Rookie


Joined: 27 Apr 2003
Posts: 20

PostPosted: Sun Apr 27, 2003 5:04 pm    Post subject: Getting smarty vars from php code Reply with quote

Can this be done?

We can $smarty->assign() but can't $smarty->get()
I'm using an old version so this might have been implemented?
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Sun Apr 27, 2003 5:52 pm    Post subject: Reply with quote

You are probably looking for the undocumented $smarty->_tpl_vars array.
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Sun Apr 27, 2003 6:55 pm    Post subject: Reply with quote

no. $_tpl_vars is considered internal (as everything beginning with a "_").
he's looking for the documented $smarty->get_template_vars([varname])
(the varname is optional)

see:
http://smarty.php.net/manual/en/api.get.template.vars.php
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Wom.bat
Smarty Pro


Joined: 24 Apr 2003
Posts: 107
Location: Munich, Germany

PostPosted: Sun Apr 27, 2003 7:08 pm    Post subject: Reply with quote

*looking forward to php 5 and private vars*
Back to top
View user's profile Send private message
AZTEK
Smarty Pro


Joined: 16 Apr 2003
Posts: 235
Location: Purdue University

PostPosted: Sun Apr 27, 2003 7:27 pm    Post subject: Reply with quote

Wom.bat wrote:
*looking forward to php 5 and private vars*

As are we all. Personally I think in 4.3.2 they should make vars and functions that begin with _ private but thats just what I think
_________________
"Imagine a school with children that can read and write, but with teachers who cannot, and you have a metaphor of the Information Age in which we live." -Peter Cochrane
Back to top
View user's profile Send private message Visit poster's website
Wom.bat
Smarty Pro


Joined: 24 Apr 2003
Posts: 107
Location: Munich, Germany

PostPosted: Sun Apr 27, 2003 8:19 pm    Post subject: Reply with quote

no, they won't, it would screw up too much older applications

I really hope that ZE2/PHP5, with it's sophisticated features will raise the acceptance of PHP for business applications (if you don't use a f*cking application server paired with J2EE, the IT managers won't buy it)
I think of exceptions (here comes the first big laugh, zeev says developers shouldn't use them in the entire app but only "sometimes", as exceptions have memory leaks), better OO model ((de)constructors, "correct" referencing and cloning, private/public/protected, interfaces, abstract classes (mmmmh), __call/__set/__get, statics, namespaces, autoloaders) etc... it's mainly OO-related stuff, and as I like OO, I can't stand waiting for the day PHP5 is officially released (I'm still to lazy to leech a snapshot Wink)
Back to top
View user's profile Send private message
Tom Sommer
Administrator


Joined: 16 Apr 2003
Posts: 47
Location: Denmark

PostPosted: Sun Apr 27, 2003 8:43 pm    Post subject: Reply with quote

Don't get PHP5 snapshot... Word has it it's leaking so much memory that it's no where near production quality yet

I'm not really looking forward to PHP5 that much, I don't see what all this namespace and inter(what's it's name) is usefull for

I heard PHP5 would make your PHP4 apps go slower... tsk

and this can't be done in PHP5:

Code:
<?php
class foo {
var $bar = NULL;

}
$foo = new foo;
$foo->bar = 'something';
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Wom.bat
Smarty Pro


Joined: 24 Apr 2003
Posts: 107
Location: Munich, Germany

PostPosted: Sun Apr 27, 2003 9:15 pm    Post subject: Reply with quote

eh why not, tom?
Back to top
View user's profile Send private message
AZTEK
Smarty Pro


Joined: 16 Apr 2003
Posts: 235
Location: Purdue University

PostPosted: Sun Apr 27, 2003 9:30 pm    Post subject: Reply with quote

I downloaded the php5 snaps a while ago, they did leak a shitload of memory but Tom I am almost 100% sure that code would work if not it would be because PHP assumes you start in private mode unless you specify.
_________________
"Imagine a school with children that can read and write, but with teachers who cannot, and you have a metaphor of the Information Age in which we live." -Peter Cochrane
Back to top
View user's profile Send private message Visit poster's website
Wom.bat
Smarty Pro


Joined: 24 Apr 2003
Posts: 107
Location: Munich, Germany

PostPosted: Sun Apr 27, 2003 9:37 pm    Post subject: Reply with quote

I think that's what Tom was thinking, AZTEK
php assumes public mode per default
Back to top
View user's profile Send private message
Tom Sommer
Administrator


Joined: 16 Apr 2003
Posts: 47
Location: Denmark

PostPosted: Sun Apr 27, 2003 9:49 pm    Post subject: Reply with quote

Read this: http://www.php-con.com/2003/east/interviews/hughes.php

Then we'll talk Smile
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Wom.bat
Smarty Pro


Joined: 24 Apr 2003
Posts: 107
Location: Munich, Germany

PostPosted: Sun Apr 27, 2003 10:12 pm    Post subject: Reply with quote

err, tom... I guess you didn't understand the article Wink
THIS is not possible:
Code:
class foo
{
}
$foo = new foo;
$foo->bar = 'something';
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Sun Apr 27, 2003 10:37 pm    Post subject: Reply with quote

that's what i read too. maybe sterling wanted to say this *won't* be possible.
both (Tom's and your example) work fine with my php4-cvs and ZE2.

me, being dumb wrote:

anyway, it pukes at:
'require_once $this->compiler_class;' due to "unexpected T_OBJECT_OPERATOR"
and smarty has some other (fully legal php4) syntactical niftynesses here and there that could render it a good backward-compatibility-smoke-test for the php5-developers. i don't mean the stuff they documented as deprecated, i mean the parts they didn't think about Smile

and as i wrote ">=4.0.6 and <5": this implied versions tagged as "release", of course. Smile
noone here will give you support when smarty breaks in development version. it's always the development that's broken in the first place.
really Very Happy


hmm, i intermixed this with another thread. sorry for disturbing. i know: i'll move along, nothing to see here... Smile
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Tom Sommer
Administrator


Joined: 16 Apr 2003
Posts: 47
Location: Denmark

PostPosted: Sun Apr 27, 2003 11:14 pm    Post subject: Reply with quote

Wom.bat wrote:
err, tom... I guess you didn't understand the article Wink
THIS is not possible:
Code:
class foo
{
}
$foo = new foo;
$foo->bar = 'something';
*Feels dumb*

BTW messju.. I assume you mean php5-CVS Smile
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Sun Apr 27, 2003 11:25 pm    Post subject: Reply with quote

hmm. it seems i got some things seriously wrong here. i used php4-cvs-head, but i used zend-engine2. i thought the object-related-features would more concern ze2 than the php-version that uses it. hmgrmpf. it seems i have to verify this with php5 again.

anyway: it was a cool site, that headed me to the hughes-interview 1-2 weeks ago Wink
Back to top
View user's profile Send private message Send e-mail 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 -> Feature Requests All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
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