howto render Footer insight/from an action


my current application-design is an 1 column design.

This column provides an menu on the left and the $content on the middle/right part.


Description of the image:

*red: main/global layout

*yellow: header, part of the main.php

*blue (all kind of blue): part of column1

**dark blue on the right: content ($content) of an action created with render()

Now I need to add an banner (green). The content is available at the action. This means, it is part of $content. But in this case, the width of the banner would be maximum the width of $content. But it should be span over menu (light blue, left) and $content.

This means: starting from the action (where the data is created) i have to render content to the colum1.php or main.php (view) "level".

Is this possible?

Is renderFooterCellContent() an valid way? But how to implement this?

Thank you, rall0r

The layout should really be done in your view file so that you have a placeholder for the banner (footer) content.

The view would look something like this:

<div id="container">

    <div id="header">

        header content...


    <div id="menu">

        menu content...


    <div id="content">

        main content...


    <div id="footer">

        <?php echo $myBanner; ?>



If you are trying to ‘inject’ the banner into the layout I suppose you could do something like this in your controller just before the render call:

//open the div

$data['myBanner'] = "<div style='width:100%; float:left; clear:both;'>\n";

//add content for div

$data['myBanner'] .= "This is my banner content.\n";

//close the div

$data['myBanner'] .= "</div>\n";

Then under your main content before the closing container div just add

<?php echo $myBanner; ?>

I can’t really help any further unless you show me your controller and view. I need to see how you are passing the data to the view and the structure of the view.

take a look CPortlet, maybe can help you solve the problem :D


my layout structure contains an view (index.php) this view is renderd at the controller/action.

If you look at this:

the index.php view creates the "medium" blue box at the middle/right.

The dark blue box (in the background) is, what the column1.php view contains: the menu as an CMenu widget on the left side (light blue) and the content of the view (above) on the right side.

If you take a look at the column1.php, at this point the content of the index.php will be pasted into the columnt1.php:

	<div id="mainBox" style="float: right; width: 53em; ">

		<?php echo $content; ?>

	</div><!-- content -->

This (using $content) is not my own code - it comes from an Yii example/testdrive.

I don’t know where $content is coming from/where $content gets his content. And i don’t know, how to pass an filled variable to this place (which would solve the problem/question) - like $content_footer.

Any ideas?

My layout structure is the same like this: (i think)

Finally an global layout, defined at main.php will be merged with the content of colum1 (which is default handling by Yii) Same question: how to pass an variable from an action to the main-layout view?


the point is: I follow your link, read the documentation, translate this into my native language but finaly i’m unable to to bring those informations to an abstract level in order to apply this to my application.

This means: i understand all the word’s i’m reading, but don’t get the sense: “what does the author trying to say?” In my (personal) case: an example at the documentation is missing! :frowning:

This is a very simple and stripped down example of passing variables from your controller to your view.

// file: controllers/TestController.php

class TestController extends Controller


    public function actionIndex()


        // create a single variable

        $myHeading = "This is my heading text";


        // create an array

        $data['myParagraphA'] = "This is my first paragraph.";

        $data['myParagraphB'] = "This is my second paragraph.";

        // send this stuff to the view

        $this->render('index', array('myHeading'=>$myHeading, 'data'=>$data));



// file: views/test/index.php

<div id="someDiv">

    <h1><?php echo $myHeading; ?></h1>

    <p><?php echo $data['myParagraphA']; ?></p>

    <p><?php echo $data['myParagraphB']; ?></p>


The view file directly above will normally be wrapped by your layout file.

By that, I mean that the view ‘index.php’ becomes the variable ‘$content’ that you see in your layout.

Perhaps the docs might help you understand a little more here:

Good luck.


thank you for the example. But, passing an variable to the view (which will be rendered) is not an problem. The problem resist one level above: column1.php

Right, that’s the point and i’m unable to pass an variable to the place where $content is “echoed”.

>Good luck.

Thank you. This is what I need, at this point. :-/

//Update: one way could be using an application component. An class which is located at $yii-path/protected/components/myClass.php. An method from this class can be called everywhere. Next step (i think) is to put this return value into an widget.


You can access the controller by ‘$this’ in the layout view.

For example, the layout view ‘main.php’ of the blog tutorial renders the page title and breadcrumbs by accessing the controller properties of ‘pageTitle’ and ‘breadcrumbs’.

	<title><?php echo CHtml::encode($this->pageTitle); ?></title>


	<?php $this->widget('zii.widgets.CBreadcrumbs', array(


	)); ?><!-- breadcrumbs -->

You can add a new property to your base controller(usually it is ‘/protected/components/Controller.php’), and prepare it in your contents views.

And, you can just render it in the layout view. :)