Created
November 24, 2014 17:55
-
-
Save acodesmith/93d8d95388be404852a1 to your computer and use it in GitHub Desktop.
renderPartial every file in a certain view folder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//View Location to auto load all .php files | |
$viewLocation = 'admin/variantRules/options'; | |
//PHP glob function will return array. If there is an error double check your path | |
foreach (glob( Yii::app()->basePath."/views/".$viewLocation."/*.php") as $filename) | |
{ | |
//Render every partial and load data | |
$this->renderPartial('//'.$viewLocation.'/'. str_replace('.php', '', array_pop( explode('/',$filename) ) ), array() ); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Heads up! This only works inside a controller. If you need this to be done in a widget or component you will need to tweak render method to just render, not renderPartial.
Yii 1!