1

それで、私は最近 Smarty を発見しました。これは非常に優れたテンプレート エンジンであると言わざるを得ません。とにかく、私はこの PHP CMS タイプのソフトウェアで作業します。

「userpanel/」ディレクトリをスマートに操作し、同時に「public_html」ディレクトリの index.php から作成された他のテンプレート呼び出しを操作しようとしています。

現在のファイル構造。/home/user/public_html/ ./ ../ includes/ libs/ templates/ templates_c/ userpanel/

「userpanel」ディレクトリのインデックス ファイル。user@userdomain.com [~/public_html/]# cat userpanel/index.php

<?php
require '../libs/Smarty.class.php';

$smarty = new Smarty;

$smarty = new Smarty;
$smarty->setTemplateDir('../templates');
$smarty->assign('title', 'My CMS');
$smarty->assign('page', 'home');
$smarty->display('userpanel/main.tpl');


?>

そして、これがテンプレートの構造です。

/home/user/public_html/templates/
./  ../  userpanel/

「userpanel」はテンプレート名です。

/home/user/public_html/templates/userpanel
./  ../  content.tpl  css/  footer.tpl  header.tpl  main.tpl

これは main.tpl のコードです。フッター/ヘッダー/コンテンツは読み込まれますが、CSS はありません。

user@userdomain.com [~/public_html/templates/userpanel]# cat main.tpl 
<html>
<head>
<title>{$title}</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
{include file='userpanel/header.tpl'}
{include file='userpanel/content.tpl'}
<br />
{include file='userpanel/footer.tpl'}
</body>
</html>

「templates/userpanel/css/style.css」と「userpanel/css/style.css」を試してみました

しかし、それらは失敗します。

とにかく、物事を短くするために。管理パネルと index.php ファイルに Smarty を使用するにはどうすればよいでしょうか? また、CSS ファイルがロードされないのはなぜですか?

ありがとうございました。

4

0 に答える 0