Smarty に .php ファイルを含め、Smarty の検索入力から $_POST データを処理し、結果を .tpl ファイルに表示する方法は? smartyコントローラーまたは構成ファイルでsearch.phpを正しく定義する方法は? 私は現在 smarty エンジンの初心者であり、このエンジンに関する多くのことやトリックを知りません
index.php smarty コア
<?php
//ob_start('ob_gzhandler');
$t1 = microtime ( 1 );
session_start ();
header ( "Content-Type: text/html; charset=utf-8" );
require_once ("inc/initf.php");
//require_once("/verjani/public_html/inc/search.php");//how to include ?
$smarty = new Smarty ();
// $smarty->debugging = true;
// $smarty->error_reporting = E_ALL & ~E_NOTICE;
$smarty->cache_dir = THEM_PATH . "/cache";
$smarty->template_dir = THEM_PATH . "/template";
$smarty->compile_dir = THEM_PATH . "/template_c";
Helper::register($smarty);
$frontEnd = new frontEnd ();
$module = $frontEnd->getModule ();
$module->viewHeaders ();
if ($module->displayTpl !== false) {
$smarty->assign ( 'COOKIE', $_COOKIE );
$smarty->assign ( 'this', $module );
$smarty->display ( $module->displayTpl, md5 ( $_SERVER ['REQUEST_URI'] ) );
}
$t = microtime();
echo '<!--'.$t.'-->';
http://www.smarty.net/docs/en/language.function.foreach.tpl#idp8696576のsearch.php
<?php
include('Smarty.class.php');
$smarty = new Smarty;
$dsn = 'mysql:host=localhost;dbname=test';
$login = 'test';
$passwd = 'test';
// setting PDO to use buffered queries in mysql is
// important if you plan on using multiple result cursors
// in the template.
$db = new PDO($dsn, $login, $passwd, array(
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true));
$res = $db->prepare("select * from users");
$res->execute();
$res->setFetchMode(PDO::FETCH_LAZY);
// assign to smarty
$smarty->assign('res',$res);
$smarty->display('index.tpl');?>
?>
header.tpl.html
<form method="post" action="../search.php" class="searchform cf">
<input type="text" placeholder="">
<button type="submit">Search</button>
</form>