In J1.5 examples and books, assign() and assignref() are used to pass data from a view into the layout. I noticed that these seem to be replaced in J1.6 and above by just adding the data to the view object. Are assign and assignref needed any more and if so, under what circumstances should I use them?
assign() and assignRef() are not needed anymore, since Joomla 1.6/2.5 requires at least PHP 5.2, which has far better memory management, which is the main reason why those two methods were introduced. Those two methods are assigning the variables by reference and not by value. PHP4 by default used assign by value, while PHP5 (when using objects) uses assign by reference.
Bottom line: You don't need assign() and assignRef() anymore.
> In J1.5 examples and books, assign() and assignref() are used to pass > data from a view into the layout. > I noticed that these seem to be replaced in J1.6 and above by just > adding the data to the view object. > Are assign and assignref needed any more and if so, under what > circumstances should I use them?
> -- > You received this message because you are subscribed to the Google > Groups "Joomla! General Development" group. > To view this discussion on the web, visit > https://groups.google.com/d/msg/joomla-dev-general/-/MDQTvTtWE_wJ. > To post to this group, send an email to > joomla-dev-general@googlegroups.com. > To unsubscribe from this group, send email to > joomla-dev-general+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/joomla-dev-general?hl=en-GB.
If anyone's bored, I think a patch that gets rid of all calls to assign() and assignRef() would be awesome. They're not gonna be around forever and than we don't have to worry about them down the road.
> assign() and assignRef() are not needed anymore, since Joomla 1.6/2.5 > requires at least PHP 5.2, which has far better memory management, which > is the main reason why those two methods were introduced. Those two > methods are assigning the variables by reference and not by value. PHP4 > by default used assign by value, while PHP5 (when using objects) uses > assign by reference.
> Bottom line: You don't need assign() and assignRef() anymore.
> Hannes
> Am 21.03.2012 19:24, schrieb Richard: >> In J1.5 examples and books, assign() and assignref() are used to pass >> data from a view into the layout. >> I noticed that these seem to be replaced in J1.6 and above by just >> adding the data to the view object. >> Are assign and assignref needed any more and if so, under what >> circumstances should I use them?
>> -- >> You received this message because you are subscribed to the Google >> Groups "Joomla! General Development" group. >> To view this discussion on the web, visit >> https://groups.google.com/d/msg/joomla-dev-general/-/MDQTvTtWE_wJ. >> To post to this group, send an email to >> joomla-dev-general@googlegroups.com. >> To unsubscribe from this group, send email to >> joomla-dev-general+unsubscribe@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/joomla-dev-general?hl=en-GB.
> -- > You received this message because you are subscribed to the Google Groups "Joomla! General Development" group. > To post to this group, send an email to joomla-dev-general@googlegroups.com. > To unsubscribe from this group, send email to joomla-dev-general+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.
How to we pass vars to the display then? I can't seem to get default.php to display mine. The print_r inside of the view prints the data just fine. O.O
On Saturday, August 4, 2012 5:20:36 AM UTC+2, Xerosigma wrote:
> How to we pass vars to the display then? I can't seem to get default.php > to display mine. The print_r inside of the view prints the data just fine. > O.O
> Just use $this->variable = $something; in your view.html.php and it will
> be available in the layout.
> Cheers,
> Daniel
> On Saturday, August 4, 2012 5:20:36 AM UTC+2, Xerosigma wrote:
>> How to we pass vars to the display then? I can't seem to get default.php
>> to display mine. The print_r inside of the view prints the data just fine.
>> O.O
> To post to this group, send an email to
> joomla-dev-general@googlegroups.com.
> To unsubscribe from this group, send email to
> joomla-dev-general+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/joomla-dev-general?hl=en-GB.
Just wondering, all core view classes ('view.html.php') in CMS 2.5 have these variables ($data, $item) protected and thus cannot be set directly from controller. That's what Rouven was speaking about? To change to
View: class HelloworldViewHello { public $data; // ...
On Saturday, August 4, 2012 2:07:24 PM UTC+2, Daniel Dimitrov wrote:
> Just use $this->variable = $something; in your view.html.php and it will > be available in the layout. > Cheers, > Daniel
> On Saturday, August 4, 2012 5:20:36 AM UTC+2, Xerosigma wrote:
>> How to we pass vars to the display then? I can't seem to get default.php >> to display mine. The print_r inside of the view prints the data just fine. >> O.O