Using frames in layout

Dear all,

I want to use frames in my layout main.php file. I want to have menues from one frame, content from other and footer from last frame. I tried the following -




<?php $menuurl = Yii::app()->createUrl('site/menu');?>

<?php $contenturl = Yii::app()->createUrl('site/login');?>

<?php $footerurl = Yii::app()->createUrl('site/footer');?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<meta name="language" content="en" />

<link rel="stylesheet" type="text/css" href="<?php echo  Yii::app()->request->baseUrl; ?>/css/main.css" />

<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/form.css" />

<title><?php echo $this->pageTitle; ?></title>

</head>


<body>

<frameset id="myframeset" rows="12%,86%,*" frameborder=0 noresize framespacing=0>

<frame frameborder=0 name="title" src="<?=$menuurl?>" scrolling = "no" noresize marginwidth="0" marginheight=0>

<frame frameborder=0 name="main" src="<?=$contenturl?>" marginwidth="0" marginheight="0" >

<frame frameborder=0 name="footer" scrolling = "no" noresize src="<?=$footerurl?>" marginwidth="0" marginheight=0>

</frameset>




But its not working! Its giving plane white screen.

I might be wrong?

Any Idea?

Hi again,

I got the frames working, but I am facing problems with the content frame, my content frame is  



<frame frameborder=0 name="main" src="<?php echo Yii::app()->createUrl('/site/content');?>" scrolling = "no" noresize marginwidth="0" marginheight=0>



and my content view is like -

/protected/views/site/content.php




<?php echo $content ?>



So if I click on any menu from the top frame , its not displaying contents in the content frame. Even I am targeting menues to the "main" frames.

Is there any way to access the $content var in the layout/main.php in other view files?

Thanks in advance!

I think there is no way to use html frames in yii or its not easy the way i want.

     Anybody if knows anything please tell me.

Thanks!

First, you have to create a special layout for your frameset (e.g. "frameset.php"):




<?php $menuurl = Yii::app()->createUrl('/site/menu');?>

<?php $contenturl = Yii::app()->createUrl('/site/login');?>

<?php $footerurl = Yii::app()->createUrl('/site/footer');?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">


<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<meta name="language" content="en" />

<link rel="stylesheet" type="text/css" href="<?php echo  Yii::app()->request->baseUrl; ?>/css/main.css" />

<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/form.css" />

<title><?php echo $this->pageTitle; ?></title>

</head>


<frameset id="myframeset" rows="12%,86%,*" frameborder=0 noresize framespacing=0>

<frame frameborder=0 name="title" src="<?=$menuurl?>" scrolling = "no" noresize marginwidth="0" marginheight=0>

<frame frameborder=0 name="main" src="<?=$contenturl?>" marginwidth="0" marginheight="0" >

<frame frameborder=0 name="footer" scrolling = "no" noresize src="<?=$footerurl?>" marginwidth="0" marginheight=0>

</frameset>


</html>



As you can see, the DOCTYPE must be:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">.

Also there is must not be <body> tag.

In the SiteController, actionIndex you should write:




$this->layout = 'frameset';



Other actions must use another layout, "main" by default (not a frameset).

A menu view, which is rendered in the site/menu action, should look like:




[ <?php echo CHtml::link('Link 1', array('/site/action1'), array('target'=>'main')); ?> ]

[ <?php echo CHtml::link('Link 2', array('/site/action2'), array('target'=>'main')); ?> ]

// and so on...



That should work, but notice, when you are using a frameset, 3 different applications are created (for the menu, content and footer respectively), and that is not good at all.

Thanks andy_s!

      Its working perfectly fine&#33; I was struggling for that since last 3 days ,but now I got it working. 


      Can you tell me why we need two different layouts (i.e. frameset and main)?

Thanks again!

Just imagine: you have the only layout and it is a frameset. Then an each frame will be a frameset too, because menu, content and footer will render their views using that frameset layout (and an each frame will be a … :rolleyes:). I don’t know, how does a browser handle this situation, but, as you can see, nothing works.

hii

i am newbie in yii framework i am having problem in frameset

can you tell me how to use that i created main.php layout and frameset layout but while i am running it

its showing frames in top/left and main

urgent needy