exneval exneval - 1 year ago 65
PHP Question

How to implement this kind of layout in new model?



there are

<?php $this->beginContent('@dektrium/user/views/admin/update.php', ['user' => $user]) ?>
'the rest codes'
<?php $this->endContent() ?>

and in

<div class="col-md-9">
<div class="panel panel-default">
<div class="panel-body">
<?= $content ?>

will be replaced by code between 'beginContent' and 'endContent', how to implement this kind of layout in my new backend model 'Rayon'? I tried write a similar CRUD code, but keep getting an error 'Undefined variable content'.

Thank you for your help.

Answer Source

the row with code

 <?php $this->beginContent('@dektrium/user/views/admin/update.php', ['user' => $user]) ?>

tells to the "view" which is, to take the code from the reference and add it to the place where the call is invoked ..

It performs an equivalent action to "include" within more the possibility of pass the variables to use in the "content"

then you should create the part of view that you want to reuse .. and the views in which you want to call to add this type of call

You can do something similar directly reusing the render () function inside de view and indicating which (other) view and which variables to use.

for (simple) example

view container_view.php in yourapp/views

 <div>my container test</div>
 <?= $content ?>

then You want that the code in container_view is placed in a way that the code inside beginContent and endContent of the

create.php in yourapp/views/ is place in the same place you have $content in the container

<?php $this->beginContent('yourapp/views/container_view.php', ['model' => $model]) ?>
 <div>this code is placed in $container</div>
 <div>and the value of the var model is passed</div>
 <br />
 <?= $model->name '>
 <?php $this->endContent() ?>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download