awebdeveloper, on 20 January 2013 - 01:22 PM, said:
Here is a simplified html of my template
//some static content
For all ajax request i just want to load the content inside "right" but for all others it's the whole thing. The left content is same in most cases but changes in a few cases. So Is there a way i can override a block in the layout without using a variable to hold html something using BeginContent.
To make myself clear
- For ajax requests i only render the view with ajax layout
- For non ajax requests i render main template with view
- For a few non ajax requests i render main template with view but i want a few changes in the main template content.
PS: I am aware of "renderPartial" and request->isAjaxRequest. My concern is the conetnt part
Hi, let me try to give some response ...
You can set up multiple layouts in Yii ... by default in the protected/views/layouts/ folder you will find column1.php and column2.php. In your controller you can change the layout that is being used as follows:
where layoutxxx is a layout you created
So, if you want to have 2 columns for example and have the right column load via ajax you could try something as follows (in layoutxxx.php):
<?php $this->beginContent('application.views.layouts.main'); ?>
<div class="span-5 last">
</div><!-- sidebar -->
<!--?php echo $content; ?-->
$data = array();
$data["content"] = $content;
$this->renderPartial('/layouts/column1', $data); ?>
</div><!-- content -->
<?php $this->endContent(); ?>