Ok, first of all thanks for your advice. I tried your code but it gives me an error
Undefined variable: dataProvider
Here are the controllers actionIndex() methods.
class FrontPageCategoriesController extends Controller {
public function actionIndex() {
$dataProvider = new FrontPageCategories;
$this->render('index', array(
'dataProvider' => $dataProvider,
));
}
}
class TopProductsController extends Controller {
public function actionIndex() {
$dataProvider = new TopProducts;
$this->render('index', array(
'dataProvider' => $dataProvider,
));
}
}
And here is the view file /frontPageControllers/views/index.php
<div id="work" class="page">
<div class="container">
<!-- Title Page -->
<div class="row">
<div class="span12">
<div class="title-page">
<h2 class="title">Welcome To Easy Aesthetics</h2>
<h3 class="title-description">Check Out New Supplements Prices in <a href="#">here</a>.</h3>
</div>
</div>
</div>
<!-- End Title Page -->
<!-- Portfolio Projects -->
<div class="row">
<div class="span3">
<!-- Filter -->
<nav id="options" class="work-nav">
<ul id="filters" class="option-set" data-option-key="filter">
<li class="type-work">Categories</li>
<li><a href="#filter" data-option-value="*" class="selected">All</a></li>
<li><a href="#filter" data-option-value=".design">Training</a></li>
<li><a href="#filter" data-option-value=".photography">Nutritions</a></li>
<li><a href="#filter" data-option-value=".video">Video</a></li>
</ul>
</nav>
<!-- End Filter -->
</div>
<div class="span9">
<div class="row">
<section id="projects">
<ul id="thumbs">
<!-- Item Project and Filter Name -->
<li class="item-thumbs span3 design">
<!-- Fancybox - Gallery Enabled - Title - Full Image -->
<?php
$liValue = $dataProvider->findByPk(1);
$summaryTextParts = explode(";;;", $liValue->summary);
?>
<a class="hover-wrap fancybox" data-fancybox-group="gallery" title="<?php $liValue->summary_title; ?>" href="<?php echo $liValue->image_path; ?>">
<span class="overlay-img"></span>
<span class="overlay-img-thumb font-icon-plus"></span>
</a>
<!-- Thumb Image and Description -->
<img src="<?php echo $summaryTextParts[0]; ?>" alt="<?php echo $summaryTextParts[1]; ?>">
</li>
<!-- End Item Project -->
<!-- Item Project and Filter Name -->
<li class="item-thumbs span3 design">
<!-- Fancybox - Gallery Enabled - Title - Full Image -->
<?php
$liValue = $dataProvider->findByPk(2);
$summaryTextParts = explode(";;;", $liValue->summary);
?>
<a class="hover-wrap fancybox" data-fancybox-group="gallery" title="<?php $liValue->summary_title; ?>" href="<?php echo $liValue->image_path; ?>">
<span class="overlay-img"></span>
<span class="overlay-img-thumb font-icon-plus"></span>
</a>
<!-- Thumb Image and Description -->
<img src="<?php echo $summaryTextParts[0]; ?>" alt="<?php echo $summaryTextParts[1]; ?>">
</li>
<!-- End Item Project -->
<!-- Item Project and Filter Name -->
<li class="item-thumbs span3 photography">
<!-- Fancybox - Gallery Enabled - Title - Full Image -->
<?php
$liValue = $dataProvider->findByPk(5);
$summaryTextParts = explode(";;;", $liValue->summary);
?>
<a class="hover-wrap fancybox" data-fancybox-group="gallery" title="<?php $liValue->summary_title; ?>" href="<?php echo $liValue->image_path; ?>">
<span class="overlay-img"></span>
<span class="overlay-img-thumb font-icon-plus"></span>
</a>
<!-- Thumb Image and Description -->
<img src="<?php echo $summaryTextParts[0]; ?>" alt="<?php echo $summaryTextParts[1]; ?>">
</li>
<!-- End Item Project -->
<!-- Item Project and Filter Name -->
<li class="item-thumbs span3 video">
<!-- Fancybox Media - Gallery Enabled - Title - Link to Video -->
<?php
$liValue = $dataProvider->findByPk(<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/cool.gif' class='bbc_emoticon' alt='8)' />;
?>
<a class="hover-wrap fancybox-media fancybox.iframe" data-fancybox-group="video" title="<?php $liValue->summary_title; ?>" href="<?php echo $liValue->summary; ?>">
<span class="overlay-img"></span>
<span class="overlay-img-thumb font-icon-plus"></span>
</a>
<!-- Thumb Image and Description -->
<img src="<?php echo $liValue->image_path; ?>" alt="Video">
</li>
<!-- End Item Project -->
<!-- Item Project and Filter Name -->
<li class="item-thumbs span3 photography">
<!-- Fancybox - Gallery Enabled - Title - Full Image -->
<?php
$liValue = $dataProvider->findByPk(6);
$summaryTextParts = explode(";;;", $liValue->summary);
?>
<a class="hover-wrap fancybox" data-fancybox-group="gallery" title="<?php $liValue->summary_title; ?>" href="<?php echo $liValue->image_path; ?>">
<span class="overlay-img"></span>
<span class="overlay-img-thumb font-icon-plus"></span>
</a>
<!-- Thumb Image and Description -->
<img src="<?php echo $summaryTextParts[0]; ?>" alt=" <?php echo $summaryTextParts[1]; ?> ">
</li>
<!-- End Item Project -->
<!-- Item Project and Filter Name -->
<li class="item-thumbs span3 photography">
<!-- Fancybox - Gallery Enabled - Title - Full Image -->
<?php
$liValue = $dataProvider->findByPk(7);
$summaryTextParts = explode(";;;", $liValue->summary);
?>
<a class="hover-wrap fancybox" data-fancybox-group="gallery" title="<?php $liValue->summary_title; ?>" href="<?php echo $liValue->image_path; ?>">
<span class="overlay-img"></span>
<span class="overlay-img-thumb font-icon-plus"></span>
</a>
<!-- Thumb Image and Description -->
<img src="<?php echo $summaryTextParts[0]; ?>" alt="<?php echo $summaryTextParts[1]; ?> ">
</li>
<!-- End Item Project -->
<!-- Item Project and Filter Name -->
<li class="item-thumbs span3 video">
<?php
$liValue = $dataProvider->findByPk(9);
?>
<!-- Fancybox Media - Gallery Enabled - Title - Link to Video https://www.youtube.com/watch?v=yuTyZMxrPMQ -->
<a class="hover-wrap fancybox-media fancybox.iframe" data-fancybox-group="video" title="<?php $liValue->summary_title; ?>" href="<?php echo $liValue->summary; ?>">
<span class="overlay-img"></span>
<span class="overlay-img-thumb font-icon-plus"></span>
</a>
<!-- Thumb Image and Description -->
<img src="<?php echo $liValue->image_path; ?>" alt="Video">
</li>
<!-- End Item Project -->
<!-- Item Project and Filter Name -->
<li class="item-thumbs span3 design">
<!-- Fancybox - Gallery Enabled - Title - Full Image -->
<?php
$liValue = $dataProvider->findByPk(3);
$summaryTextParts = explode(";;;", $liValue->summary);
?>
<a class="hover-wrap fancybox" data-fancybox-group="gallery" title="<?php $liValue->summary_title; ?>" href="<?php echo $liValue->image_path; ?> ">
<span class="overlay-img"></span>
<span class="overlay-img-thumb font-icon-plus"></span>
</a>
<!-- Thumb Image and Description -->
<img src="<?php echo $summaryTextParts[0]; ?>" alt="<?php echo $summaryTextParts[1]; ?>">
</li>
<!-- End Item Project -->
<!-- Item Project and Filter Name -->
<li class="item-thumbs span3 design">
<!-- Fancybox - Gallery Enabled - Title - Full Image -->
<?php
$liValue = $dataProvider->findByPk(4);
$summaryTextParts = explode(";;;", $liValue->summary);
?>
<a class="hover-wrap fancybox" data-fancybox-group="gallery" title="<?php $liValue->summary_title; ?>" href="<?php echo $liValue->image_path; ?>">
<span class="overlay-img"></span>
<span class="overlay-img-thumb font-icon-plus"></span>
</a>
<!-- Thumb Image and Description -->
<img src="<?php echo $summaryTextParts[0]; ?>" alt="<?php echo $summaryTextParts[1]; ?>">
</li>
<!-- End Item Project -->
</ul>
</section>
</div>
</div>
</div>
<!-- End Portfolio Projects -->
</div>
</div>
Here is the TopProducts view file located in topProducts/views/index.php
<div id="about" class="page-alternate">
<div class="container">
<!-- Title Page -->
<div class="row">
<div class="span12">
<div class="title-page">
<h2 class="title">Top Products</h2>
<h3 class="title-description">Check Out The Cheap Prices On These Products</h3>
</div>
</div>
</div>
<!-- End Title Page -->
<!-- People -->
<div class="row">
<!-- Start Profile -->
<div class="span4 profile">
<?php
$liValue = $dataProvider->findByPk(1);
?>
<div class="image-wrap">
<div class="hover-wrap">
<span class="overlay-img"></span>
<span class="overlay-text-thumb">#1 Products</span>
</div>
<img src="<?php echo $liValue->image_path; ?>" alt="#1 Product">
</div>
<h3 class="profile-name"><?php echo $liValue->title; ?></h3>
<p class="profile-description"> <?php echo $liValue->summary; ?></p>
<div class="social">
<ul class="social-icons">
<li><a href="#"><i class="font-icon-social-twitter"></i></a></li>
<li><a href="#"><i class="font-icon-social-dribbble"></i></a></li>
<li><a href="#"><i class="font-icon-social-facebook"></i></a></li>
</ul>
</div>
</div>
<!-- End Profile -->
<!-- Start Profile -->
<div class="span4 profile">
<?php
$liValue = $dataProvider->findByPk(2);
?>
<div class="image-wrap">
<div class="hover-wrap">
<span class="overlay-img"></span>
<span class="overlay-text-thumb">#2 Product</span>
</div>
<img src="<?php echo $liValue->image_path; ?>" alt="#2 Product">
</div>
<h3 class="profile-name"><?php echo $liValue->title; ?></h3>
<p class="profile-description"><?php echo $liValue->summary; ?></p>
<div class="social">
<ul class="social-icons">
<li><a href="#"><i class="font-icon-social-twitter"></i></a></li>
<li><a href="#"><i class="font-icon-social-email"></i></a></li>
</ul>
</div>
</div>
<!-- End Profile -->
<!-- Start Profile -->
<div class="span4 profile">
<?php
$liValue = $dataProvider->findByPk(3);
?>
<div class="image-wrap">
<div class="hover-wrap">
<span class="overlay-img"></span>
<span class="overlay-text-thumb">#3 Product</span>
</div>
<img src="<?php echo $liValue->image_path; ?>" alt="#3 Product">
</div>
<h3 class="profile-name"><?php echo $liValue->title; ?></h3>
<p class="profile-description"><?php echo $liValue->summary; ?></p>
<div class="social">
<ul class="social-icons">
<li><a href="#"><i class="font-icon-social-twitter"></i></a></li>
<li><a href="#"><i class="font-icon-social-linkedin"></i></a></li>
<li><a href="#"><i class="font-icon-social-google-plus"></i></a></li>
<li><a href="#"><i class="font-icon-social-vimeo"></i></a></li>
</ul>
</div>
</div>
<!-- End Profile -->
</div>
<!-- End People -->
</div>
</div>
<!-- End About Section -->
And finally here is the site/views/index.php
<?php
/* @var $this SiteController */
$this->pageTitle=Yii::app()->name;
$this->render('//frontPageCategories/index');
$this->render('//topProducts/index');
?>
So, you see i want to include those view files in the above site/views/index.php. How would i do that ? Is there even a way to do that without resorting to PHP’s require_once() method.
Thanks,
Maxx