为什么tinyButStrong在合并块时没有正确格式化我的视图?

问题描述 投票:0回答:1

这是我的控制器挑战.php

<?php
    include("../../tbs_3150/tbs_class.php");
    include("../connect.php");
    $tbs = new clsTinyButStrong;
    try {
        $pdo = new PDO($host, $login, $password);
        $message = "connexion établie";
        if(isset($_GET["category"])){
            $res = $pdo->prepare("SELECT * FROM `challenge` 
                                    WHERE `categoryId`=:categoryId;");
            $res->bindParam(":categoryId",$_GET["category"]);
            $res->execute();
            $rows = $res->fetchAll(PDO::FETCH_ASSOC);
            $tbs->MergeBlock("row",$rows);
        }
    } catch (PDOException $erreur) {
        $message = $erreur->getMessage();
    }
    $tbs->LoadTemplate("../views/challenges.html");
    $tbs->Show();
?>

这是我的看法

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>[onshow.message]</title>
</head>
<body>
    <h1>[onshow.message]</h1>
    <table>
        <thead>
            <tr>
                <th>ID</th>
                <th>Nom</th>
                <th>Description</th>
                <!-- Ajoutez d'autres colonnes si nécessaire -->
            </tr>
        </thead>
        <tbody>
            [row;block=begin]
                <tr>
                    <td>[row.challengeId]</td>
                    <td>[row.title]</td>
                    <td>[row.description]</td>
                </tr>
            [row;block=end]
        </tbody>
    </table>
</body>
</html>

我知道我正确地查询了我的数据库,但问题是 tbs 没有使用我从数据库检索的值格式化我的视图,所以这就是结果:

我期望 [row.description] 被数据库中的实际值替换

php html templating tinybutstrong
1个回答
0
投票

$tbs->LoadTemplate("../views/challenges.html");

应该放在之前

$tbs->MergeBlock("行",$rows);

© www.soinside.com 2019 - 2024. All rights reserved.