**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?
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.
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:
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.
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!
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));
}
}
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’.