Yii Framework Forum: Status update: View as object - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Status update: View as object

#1 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,907
  • Joined: 04-October 08
  • Location:DC, USA

Posted 16 April 2012 - 03:18 PM

*
POPULAR

As discussed in the following two posts, I just completed the design and implementation of View class:
http://www.yiiframew...ews-as-objects/
http://www.yiiframew...iew-and-helper/

Below are summary of the View class design. Your feedback are welcome:
  • We will still have the render() methods in controllers and widgets like we do in 1.1. However, the implementation is different. In 2.0, the render() methods in controllers/widgets will create new View objects and call their render() thereafter.
  • The View class also contains methods such as widget(), beginCache() which in 1.1 are within CBaseController.
  • The View class contains a property named $owner which refers to the owner of the view.
  • In a view file, $this refers to the View object, while $this->owner refers to the owner of the view.
  • View renderer is no longer needed in 2.0. To support a new template syntax, one needs to extend View now.
  • Besides controllers and widgets, the View class can also be used in other places, such as console commands.


14

#2 User is offline   robregonm 

  • Experienced Yii Developer
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 648
  • Joined: 30-July 09
  • Location:Colombia

Posted 16 April 2012 - 04:56 PM

+1 for new View class and all the new features.
Rick

Support me on Patreon: https://www.patreon.com/yiiframework


Promover Yii Framework en Español en Patreon: https://www.patreon....yiiframework_es

YiiFramework en Español: http://yiiframework.es/ - Canal de YouTube - Facebook
Follow me: @robregonm.
0

#3 User is offline   Gustavo 

  • Master Member
  • Yii
  • Group: Moderators
  • Posts: 916
  • Joined: 27-July 10
  • Location:Curitiba - Brasil

Posted 16 April 2012 - 09:39 PM

great news!
What about CHtml ? Is it done ? If so, how is its design ?
--
Extensions:
translate modue - module to handle translations
multiActiveRecord - db selection in models
redisCache - redis cache component
mpCpanel - interact with cpanel api
mUploadify - use uploadify uploader in your application

Gustavo Salomé Silva
0

#4 User is offline   yiqing95 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 608
  • Joined: 27-December 10
  • Location:china

Posted 17 April 2012 - 01:44 AM

:lol:

looks great!
0

#5 User is offline   phpnode 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 141
  • Joined: 18-April 11

Posted 17 April 2012 - 06:17 AM

Looks great, I'm also wondering about how CHtml will work, will it be e.g. echo $this->html->activeTextField() ?
0

#6 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,951
  • Joined: 17-January 09
  • Location:Russia

Posted 17 April 2012 - 07:41 AM

CHtml is still there.
Yii 2.0 Development Cookbook

Enjoying Yii? Star us at github

Support me so I work on Yii fulltime: https://www.patreon.com/samdark
0

#7 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 3,467
  • Joined: 10-October 10
  • Location:Denmark

Posted 17 April 2012 - 01:57 PM

Really nice!

This means that we can tell Yii to render different media/content types?

For instance, based on what is requesting data, and what method is used, the controller could decide what view object to use - JSON or XML for rest requests and the default for regular requests?

I think I am going to like this. :)
"Less noise - more signal"
0

#8 User is offline   Orteko 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 34
  • Joined: 02-March 10

Posted 17 April 2012 - 08:05 PM

Sounds like a good move to me - one thing I would like is the ability to have a view that simply renders supplied xml with an xslt.

This sounds like it should make this much easier to implement.
0

#9 User is offline   Roman Solomatin 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 215
  • Joined: 21-October 10
  • Location:Tallinn, Estonia

Posted 17 April 2012 - 09:27 PM

I think this is a great idea.
0

#10 User is offline   binkabir 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 194
  • Joined: 25-July 10
  • Location:Abuja,Nigeria

Posted 18 April 2012 - 11:45 AM

great idea.
will the view have public methods like $this->theme='classic' ?
secondly
if i have multiple actions that use the same view object, i can do this ?
 
 $view = new View(); 
 $view::render(array('model'=>$model,'var1'=>$var1)); 

0

#11 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,951
  • Joined: 17-January 09
  • Location:Russia

Posted 22 April 2012 - 06:20 AM

binkabir
Yes, there will be some public properties. You'll be able to use View manually as Qiang already mentioned.
Yii 2.0 Development Cookbook

Enjoying Yii? Star us at github

Support me so I work on Yii fulltime: https://www.patreon.com/samdark
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users