串联MVC视图

时间:2018-11-15 15:20:00

标签: model-view-controller view model controller

在这里我有一个我无法解决的小问题。 我希望我收集了两页的postview以及如何查看。 确实,我希望合并两个视图,这是代码:

PostView.php,它允许查看帖子并将其删除:

<?php
while ($post = $posts->fetch())
{
?>
<form action="indexadmin.php?action=suprPost&amp;id=<?= $post['id'] ?>" method="post">
    Title : <input type='text' name='title' value='<?php echo $post['title']; ?>'/>
    <br /><br />
    <textarea name='content' cols="50" rows="8"><?php echo $post['content']; ?></textarea>
    <br />
    <td><?php echo $post['creation_date']; ?></td>
    <br /><br />
    <div>
        <input value="Delete" type="submit" />
    </div>
</form>
<hr>
<?php
}
$posts->closeCursor();
?>
<?php $content = ob_get_clean(); ?>

<?php require('view/frontend/template.php'); ?>

还有commentView.php,它允许查看注释并将其删除:

<?php
while ($post = $posts->fetch())
{
?>

<form action="indexadmin.php?action=deleteComment&amp;id=<?= $post['id_comment'] ?>" method="post">
<table>
   <thead>
        <tr>
           <th>Id</th>
           <th>Auteur</th>
           <th>Commentaire</th>
           <th>Date</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td><input name="id_comment" value="<?php echo $post['id_comment']; ?>"/></td>
            <td><?php echo $post['author']; ?></td>
            <td><textarea cols="50" rows="8"><?php echo $post['comment']; ?></textarea></td>
            <td><?php echo $post['comment_date']; ?></td>
       </tr>
    </tbody>
</table>
<br />
    <div>
        <input value="Delete" type="submit" />
    </div>
</form>
<br />

<?php
}
$posts->closeCursor();
?>
<?php $content = ob_get_clean(); ?>

Controller.php

function listPostsAd()
{
    $postManager = new \kev399\blog_ecrivain\model\PostManager();
    $posts = $postManager->getPosts();
    
    require('view/backend/administrationPostView.php');
}

function listCommentsAd()
{
    $postManager = new \kev399\blog_ecrivain\model\PostManager();
    $posts = $postManager->commentPosts();

    require('view/backend/administrationCommentView.php');
}

这是问题所在的屏幕:

Screen

谢谢。

0 个答案:

没有答案