Skip to content

[Help] setVar('body', $view, 'raw') #1000

Description

@BI7PRK

I created a account on forums, but i donnt know why cannt post thread. i have a problem:

Layout file:

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>test-{title}</title>
  <style> 
    {styles}
  </style>  
  </head>
  <body>
      <div class="container-fluid">
        {body}
      </div>
    <script>
     {footscript}
    </script>    
  </body>
</html>

View code:

<div class="wrap">
<ul>
				<?php foreach ($append as $item): ?>
				<li><?=$item['id'] .'='.$item['name']  ?></li>
				<?php endforeach;?>
			</ul>
</div>

Controller code:

$append = ['append' => [
	['id' => 1, 'name' => 'fsa' ],
	['id' => 2, 'name' => 'fasdf2' ],
	['id' => 3, 'name' => 'fsda3' ]

]];
$bodyview = view('welcome', $append);


$tpldata = [
	'title'=> 'page title', 
	'styles' =>'.div{ font-size:1.1em; }', 
	'footscript' =>'//var b = 1;', 
	'envir' => ENVIRONMENT 
];

$parser = \Config\Services::parser();

echo $parser->setData($tpldata)
	-> setVar('body', $bodyview, 'raw')
	-> render('layout/default');

But... page body is:

default

what should I do? thank you very much.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions