How To Remove Footer From A Page

I have a situation where I do not want a footer in one of my view. How can I achieve that without modifying the main layout file.

Thanks

Ashish Tyagi

use different layout, check protected\views\layouts\ folder, in your view file:


$this->layout = '//layouts/column_nofooter';

but I do not have any layout without footer. Do I have to create one

guess so

Probably not. :)

If you add a variable in your Controller class (from which all controllers inherit), then you can check to see if $noFooter is true or not and do some conditional coding in the layout.

It’s no big deal to just create a separate layout, though. Take a look at the other layouts in the views/layouts directory.

any code sample ? I am very new to Yii actually

This is in protected/components/Controller.php in a freshly generated Yii app:




<?php

/**

 * Controller is the customized base controller class.

 * All controller classes for this application should extend from this base class.

 */

class Controller extends CController

{

	/**

	 * @var string the default layout for the controller view. Defaults to '//layouts/column1',

	 * meaning using a single column layout. See 'protected/views/layouts/column1.php'.

	 */

	public $layout='//layouts/column1';

	/**

	 * @var array context menu items. This property will be assigned to {@link CMenu::items}.

	 */

	public $menu=array();

	/**

	 * @var array the breadcrumbs of the current page. The value of this property will

	 * be assigned to {@link CBreadcrumbs::links}. Please refer to {@link CBreadcrumbs::links}

	 * for more details on how to specify this property.

	 */

	public $breadcrumbs=array();

}

So, modify that by adding a variable to it, like public $renderFooter=True;

[i]

[/i]

And then, in any views for which the footer should be turned off, you can set it to false.

You need to modify the layout to use that variable, like:




<?php if($renderFooter) : ?>

code

<?php else: ?>

other code

<?php endif; ?>

Thanks a lot

Its not working. Can you please help me.

which is not working you mean footer? try this in Controller.php




public $renderFooter=true;



and in other controller if u don’t want to render footer insert this




public $renderFooter=false;



http://www.yiiframework.com/forum/index.php/topic/48973-removing-footer/

Also check this:


<?php if($this->renderFooter) : ?>

code

<?php else: ?>

other code

<?php endif; ?>

if $renderFooter variable belongs to Controller