Closed manishbathla closed 7 years ago
I need to call the search bar in the HomeController somewhat like this if this was codeigniter
class HomeController extends \system\core\BaseController
{
public function Index()
{
$data['page_title'] = 'xyz.com';
$data['page_description'] = 'page description here';
$data['page_keywords'] = 'keyword1, keyword2';
/***** This is where I call the Search ******/
$this->load->view('common/Search');
// And then pass $data and render template
echo $this->template->render('common/home', $data);
}
}
How do i do that with section in plates. Can you come with a small example?
Have not tried the code below,
class HomeController extends \system\core\BaseController
{
public function Index()
{
echo $templates->render('page-content::index_content',
[
'page_title' => 'xyz.com',
'page_description' => 'page description here',
'page_keywords' => 'keyword1, keyword2'
]);
}
}
<?php $this->start('main-content') ?>
<p>
//Content
</p>
<?php $this->stop() ?>
// I only show follow-thru with page title, you can do the others the same
// Since they seem like static content you probably can introduce them in
// this file and can avoid passing thru data
<?php $this->layout('main-template', ['page_title' => $this->e($page_title)]) ?>
<head>
<title><?=$this->e($page_title)?></title>
</head>
<body>
<div id="main">
<!--INSERT Search -->
<?php $this->insert('common::common-search') ?>
<div id="content">
<?php if ($this->section('main-content')): ?>
<?=$this->section('main-content')?>
<?php endif ?>
</div>
</div>
</body>
Using platesphp template engine I need to call a portion(search box) of the template in a controller.
If you have worked with Codeigniter then what I am looking is for an equivalent of $this->load->view() like the one below in phpplates
I have tried a few syntax of the platesphp but nothing seems to work.
If you have used plates, can you tell me.