Yii Framework Forum: Yii && Many Template (Themes) - Yii Framework Forum

Jump to content

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

Yii && Many Template (Themes) Rate Topic: -----

#1 User is offline   karim gioca 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 83
  • Joined: 21-September 10

Posted 27 December 2012 - 03:45 AM

Hi yii experts !
I developped an application with Yii that allow user to choose one of template (themes) sthat exist in the application,
he can swith the template whenever hewants, but my solution seems to be limited.
I explain my solution :
For example i have 5 templates to include to my application, and i have a "News" crud (NewsController and its views), so i create in views folder 5 folders that are related to NewsController :
- folder 1 :theme2_news
- folder 2 :theme2_news
- folder 3 :theme3_news
- folder 4 :theme4_news
- folder 5 :theme5_news

and when i want to swicth from one theme to an other, i do like that :
$this->render("/themex_news/create")

I tried this solution and it's great, but the problem is that when i want to add many templates (themes) i must create for each controller it's view, and when the number of template become big, the view folder will have thounds of folders.
I took a look to Yii Theming but it seems to me more limited then my solution.

Is there any ideas ??
Thanx !
0

#2 User is offline   waitforit 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 414
  • Joined: 09-February 11

Posted 27 December 2012 - 10:23 PM

Why do you need to copy the view files? Do you know you can use themes with ONE set of view files?

Are the contents of the files radically different?

I have a site with multiple themes and the only thing thats different is the css and image files for that theme (and layout, actually).
0

#3 User is offline   karim gioca 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 83
  • Joined: 21-September 10

Posted 30 December 2012 - 09:43 AM

View Postwaitforit, on 27 December 2012 - 10:23 PM, said:

Why do you need to copy the view files? Do you know you can use themes with ONE set of view files?

Are the contents of the files radically different?

I have a site with multiple themes and the only thing thats different is the css and image files for that theme (and layout, actually).


well for dynamic contnent it's actually the same, but the problem is that the design (divs and tables) are completely different. every theme must have a different design to the other.
That's why i poied the views folders, so inevery view i can put its costomized Html (same thing for layouts)

Looking in Yii Theming i descovered the same thing :
- every theme has his own folder and its own views.. or i'm wrong ?
0

#4 User is offline   KonApaz 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,327
  • Joined: 21-February 11
  • Location:Greece

Posted 30 December 2012 - 10:58 AM

Its not necessary to change the controllers and views code!

set generally the rendering
$this->render("create")

And set the theme by each user configuration like that:

in your protected/component/controller.php set the bellow method

public function render($view,$data=null,$return=false)
	{	
                $thetheme='usertheme';
		Yii::app()->setTheme($thetheme);
		return parent::render($view,$data,$return);
	}


if It is necessary set different css for each theme
Yii is the best php framework in the world!
find our demo Yii extension on www.webkit.gr
Is it post useful? please v++ ;)
0

#5 User is offline   waitforit 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 414
  • Joined: 09-February 11

Posted 31 December 2012 - 12:43 AM

You didn't answer my question.

Of course your layouts may be different for different themes. But are your View files actually different?
0

#6 User is offline   karim gioca 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 83
  • Joined: 21-September 10

Posted 03 January 2013 - 09:10 AM

View Postwaitforit, on 31 December 2012 - 12:43 AM, said:

You didn't answer my question.

Of course your layouts may be different for different themes. But are your View files actually different?

well yes actually the html for views is completely different between one theme and another so that's why i have to change the html of each view. But for dynamic content that is passed from controller it's the same.
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