Pass the view above HTML code?

Hi,

I have the following problem.

I’ve definied a main.php View where my homepage grid is.

Then I have a inner.php where I show the left and right navigation

Then I load the Views from the Controller (show, create, update…)

My question: Is it possible to set in show.php a variable that is pass to main.php?

My hierarchical structure

  • main.php

– inner.php

— show.php

— create.php

— update.php

thx!

No :)

???

no? Thats not nice :(

Well, you could try to store something in the user’s session. But that’s a bit hackish.

mmh, I see you are from Germany, so I will describe the problem on german ;)

Ich habe drei 3 Spalten Layout.

In der linken Navigation befindet sich ein Menü, dass von der darunterliegenden View abhängt.

Beispiel

  • show.php hat 3 Links in der linken Navigation

  • create.php hat 5 Links in der linken Navigation.

Ich habe ein 2 und ein 3 Spalten Layout.

Wenn das ganze nicht geht, dann müsste ich mich von dem Gedanken ein 2 und 3 Spalten Layout zu definieren verabschieden und in jede View das 2 bzw. 3 Spalten Layout mit meinen angepassten Links reinschreiben.

Das wäre total overhead :confused:

Vorallem wenn ich aus dem 3 Spalten Layout irgendwann ein 4 Spalten Layout mache möchte. Dann müsste ich ja in jede View reingehen

Take a look how this is done with the default column1.php and column2.php. I think this is what you are looking for.

thx tropi




<?php $this->beginContent('//layouts/main'); ?>

<div class="container">

		<div id="content">

			<?php echo $content; ?>

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

	<div class="span-5 last">

		<div id="sidebar">

		<?php

			$this->beginWidget('zii.widgets.CPortlet', array(

				'title'=>'Operations',

			));

			$this->widget('zii.widgets.CMenu', array(

				'items'=>$this->menu,

				'htmlOptions'=>array('class'=>'operations'),

			));

			$this->endWidget();

		?>

		</div><!-- sidebar -->

	</div>

</div>

<?php $this->endContent(); ?>



Code from yii-coloumn2.php

Is it possible to pass something from example/show.php to coloumn2.php?

Sorry, that I’m again not directly answering your question, but you might want to take a look here: http://www.yiiframework.com/wiki/249/understanding-the-view-rendering-flow/

(At the very end of the article you will get your answer anyway.)

As you see in this, every view and layout can access the properties of the controller by ‘$this->something’, like ‘$this->menu’ and ‘$this->pageTitle’.

So adding some common property to your controller might be a decent solution.