How to call a default layout for every module and how to work <php echo $content; ?>

You are viewing revision #15 of this wiki article.
This is the latest version of this article.
You may want to see the changes made in this revision.

« previous (#14)

Hi Friends, Hi Friends, Some common question is difficult to how to create the layout on yii and how to work

<?php echo $content; ?>

so in this tutorial you may help the create the common layout..and understand the

<?php echo $content; ?>

=>In this tutorial default controller is Index Controller and default action is Index

1) so first you want to create the module on config/main.php file..

                        'generatorPaths' => array(
                                'ext.giix-core', // giix generators
                'rights'=>array( 'install'=>true, // Enables the installer.

and then generate the module URL (defind config/main.php) is like http://localhost/demo/admin/index

                                'admin/'			=>'admin/index/index',
                                'admin/login'		=>'admin/index/login',
                                'admin/logout'		=>'admin/index/logout',

                                'customer/'			=>'customer/index/index',
                                'customer/login'	=>'customer/login',
                                'customer/logout'	=>'customer/index/logout',

2) i think the best way solution is you want to defined the defaultcontroller is indexcontroller and action index defined config/main.php


3) then after create the IndexController on module that extends the FrontCoreConteller apply the defult layout is main...


class IndexController extends FrontCoreController {

     * Declares class-based actions.
    public function actionIndx() {
        echo "Lorume Ipsum........"

4) Create the FrontCoreConterller.php

 * Controller is the customized base controller class.
 * All controller classes for this application should extend from this base class.
class FrontCoreController extends GxController
        public $layout='main';

        public function init()

5)Finally you want to create the layout on modules folder


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo SystemConfig::getValue('site_title');?></title>
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/main.css" />
<!--[if IE]><script src="js/html5.js"></script><![endif]-->

         <section class="wapper">
             <?php //p( yii::app()->customer)  ?>
                        <?php echo $this->renderPartial('//layouts/header');?>
                        <?php //echo $this->renderPartial('//layouts/slider');?>
                        <?php echo $content;?>

                        <?php echo $this->renderPartial('//layouts/footer');?>

in this tutorial every time call a default controller is index and action is call index so all modules default layout is main.php and write any code on index action fetch the data on

<?php echo $content ; ?>

i hope you got the my point...

0 0
1 follower
Viewed: 39 082 times
Version: Unknown (update)
Category: Tips
Written by: Ankit Modi
Last updated by: Ankit Modi
Created on: Aug 7, 2013
Last updated: 9 years ago
Update Article


View all history

Related Articles