Esempio n. 1
0
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     $ca = Carousel::model()->findAll(array('condition' => 'activo = 1 ORDER BY orden ASC'));
     $programaDestacados = Programa::model()->findAllByAttributes(array('destacado' => 1));
     $carousel = array();
     foreach ($ca as $caro) {
         $carousel[] = array('div' => '<div style="background-image: url(' . "'" . Yii::app()->request->baseUrl . '/images/carousel/' . $caro->foto . "'" . ')"></div>', 'label' => $caro->titulo, 'caption' => $caro->descripcion);
     }
     /*foreach ($programaDestacados as $programaDestacado) {
           print_r('<pre>');
           print_r($programaDestacado->programaImagens[0]->imagen);
           print_r('</pre>');
           exit;
       }*/
     // renders the view file 'protected/views/site/index.php'
     // using the default layout 'protected/views/layouts/main.php'
     $this->render('index', array('carousel' => $carousel, 'programaDestacados' => $programaDestacados));
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Carousel the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Carousel::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Esempio n. 3
0
        </div>
    </div>


    <!-- Flash 通知信息 -->
    <?php 
$this->renderPartial('//layouts/_flash_messages');
?>

    <?php 
if (Yii::app()->controller->id == "site" && Yii::app()->controller->action->id == "index") {
    ?>
        <!-- 轮播图 -->
        <div class="hidden-xs main-carousel">
            <?php 
    $carousels = Carousel::model()->findAll(array('order' => 'weight asc'));
    $carourseItems = array();
    foreach ($carousels as $carousel) {
        $item = array();
        $item['image'] = Yii::app()->baseUrl . "/" . $carousel->path;
        $item['imageOptions'] = array('style' => "width:100%;");
        if ($carousel->url) {
            $item['url'] = $carousel->url;
        }
        if ($carousel->course) {
            $item['label'] = CHtml::link($carousel->course->name, $carousel->course->pageUrl);
            $item['url'] = $carousel->course->pageUrl;
        }
        $carourseItems[] = $item;
    }
    if (count($carourseItems) > 0) {