2

我正在用 Symfony 构建一个项目。它的博客式网站。我需要实现:为每篇文章写评论。每条评论都必须经过编辑等的审核。

全部都准备好了。我有一个后端,使用组,烫发。很快。只是我需要在文章的显示页面上评论表格。

我的问题是我可以使用我的评论模块的 newSuccess temp。如果是,如何?当我复制并粘贴 newSuccess 的内容时,即使有一些配置,它也不起作用。

你知道有办法在文章模块中使用评论模块的表格吗?我该如何配置它?

感谢您花时间阅读-也许可以回答(;-

4

1 回答 1

2

只需在您的控制器中创建表单:

public function executeShowArticle(sfWebRequest $request)
{

  // assume weve already retrieved and set $this->article
  $comment = new Comment();
  $comment->setArticle($this->article);
  $this->commentForm = new CommentForm($comment);

}

然后你可以echo $commentForm在你的文章模板中使用。如果您正在自定义评论表单的布局,则将该表单移动到部分并include_partial('comment/form', array('form' => $commentForm);从您的文章视图中执行。或者,您可以制作一个组件,而不是使用直接的部分...例如:

// in commentComponents.class.php
public function executeArticleCommentForm()
{
   $comment = new Comment();
   $comment->setArticle($this->article);
   $this->form = new CommentForm($comment);
}

// in article/showArticleSuccess.php
<?php include_component('comment', 'articleCommentForm', array('article' => $article)); ?>
于 2011-01-26T05:09:57.360 回答