Yii Framework Forum: I want to create user's top - Yii Framework Forum

Jump to content

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

I want to create user's top Rate Topic: -----

#1 User is offline   dckurushin 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 392
  • Joined: 16-March 11
  • Location:Israel

Posted 24 September 2011 - 11:11 AM

Hi, I want to create my users top, I order by points...

I'm wondering just what is the best way to go...

I have inside laoyout directory, a view _sideBlock

I need to use it, cause the widget will be side column block,

When I extend CWidget and do ->render

I get a message that the

Quote

widget TopUsers can't get the view "//layouts/_sideBlock".

How can I give it the path?

The widget is inside components... the view is inside my theme as I described above

If we will look at the blog example, one can notice that the widget's views are right near in the components...
But why copy paste? there isn't a way to give it the path ? :(
0

#2 User is offline   tri 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,651
  • Joined: 20-November 08
  • Location:Stockholm, Sweden

Posted 24 September 2011 - 11:29 AM

I think this may help you out.

(not tested)
/Tommy
Don't forget to read The Definitive Guide to Yii (en) (sv) | The class reference has the details
0

#3 User is offline   dckurushin 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 392
  • Joined: 16-March 11
  • Location:Israel

Posted 24 September 2011 - 12:25 PM

It returns the view path (application\components\views), I need to take the view from the current theme... :rolleyes:

Just like in controller I use
$this->render('//layout/_sideBlock');


Need the same from inside CWidget via it's render, the documentation not helping :(
0

#4 User is offline   dckurushin 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 392
  • Joined: 16-March 11
  • Location:Israel

Posted 24 September 2011 - 12:29 PM

If listen to documentation the view is searched in themes/basic/views/Foo/xyz.php
Where Foo is CWidget name... and 'xyz' is the view

But as I described I need it to be tacken from the global theme, layout/_sideblock.php
0

#5 User is offline   dckurushin 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 392
  • Joined: 16-March 11
  • Location:Israel

Posted 24 September 2011 - 12:49 PM

This is the best I got , very ugly... but don't found another solution

$this->renderFile(Yii::app()->theme->basePath . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'layouts' . DIRECTORY_SEPARATOR . '_sideBlock.php', array(...

0

#6 User is offline   tri 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,651
  • Joined: 20-November 08
  • Location:Stockholm, Sweden

Posted 24 September 2011 - 01:51 PM

View Postdckurushin, on 24 September 2011 - 12:25 PM, said:

It returns the view path (application\components\views), I need to take the view from the current theme... :rolleyes:

Just like in controller I use
$this->render('//layout/_sideBlock');


Need the same from inside CWidget via it's render, the documentation not helping :(


If you define different themes, at least you should be able to get the corresponding view path "ThemeID/views/ClassName" by setting the checkTheme parameter.

I suppose you have a good reason not to include the widget itself in a sublayout like the Gii generated column1.php.

Sorry for not being able to help. I still have to find out more about best practice implementing modular layouts.

/Tommy
Don't forget to read The Definitive Guide to Yii (en) (sv) | The class reference has the details
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