login form when there is no comment and you're not connected
Hello,
my configuration is like that:
# app/Ressources/config/config.yml
fos_comment:
db_driver: orm
class:
model:
comment: AppBundle\Entity\Comment
thread: AppBundle\Entity\Thread
vote: AppBundle\Entity\Vote
acl: true
service:
acl:
thread: fos_comment.acl.thread.roles
comment: fos_comment.acl.comment.roles
vote: fos_comment.acl.vote.roles
manager:
thread: fos_comment.manager.thread.acl
comment: fos_comment.manager.comment.acl
vote: fos_comment.manager.vote.acl
acl_roles:
comment:
create: ROLE_USER
view: IS_AUTHENTICATED_ANONYMOUSLY
edit: ROLE_ADMIN
delete: ROLE_ADMIN
thread:
create: ROLE_USER
view: IS_AUTHENTICATED_ANONYMOUSLY
edit: ROLE_ADMIN
delete: ROLE_ADMIN
vote:
create: ROLE_USER
view: IS_AUTHENTICATED_ANONYMOUSLY
edit: ROLE_ADMIN
delete: ROLE_ADMIN
my display :
{% include 'FOSCommentBundle:Thread:async.html.twig' with {'id': post.id} %}
As you can see, when you're not connected, you can watch comment but not add. There is no problem after the first comment. But when there is no comment, the login form appear a the place of the comment and it makes some display bugs.
Is it possible to retire this login form ?
I'm facing the same issue.
I found out this is happening when you have no "Thread" entity created with the given permalink. My ugly workaround is to create that Thread in the view action...
Part of my ugly workaround. Generally this whole bundle is full of scary things...
/**
* Action: SocialPost (Single post)
*/
public function socialPostAction(Request $request, $id)
{
// Fetch single social post from MongoDB
if($socialPost = $this->get('doctrine_mongodb')->getRepository('AppBundle:SocialPost')->find($id)) {
// Workaround for: https://github.com/FriendsOfSymfony/FOSCommentBundle/issues/511
// Find matching CommentThread and pre-create one if it does not exist
$em = $this->getDoctrine()->getManager();
if(!$thread = $em->getRepository('AppBundle:CommentThread')->findOneById(['id' => $socialPost->getId()])) {
$thread = new \AppBundle\Entity\CommentThread();
$thread->setId($socialPost->getId());
$thread->setPermalink($request->getUri()); // NOTE: this in general is very poor solution; esp for working with app_dev.php
$thread->setCommentable(true);
$em->persist($thread);
$em->flush();
}
// Render
return $this->render('AppBundle:Feed:socialpost.html.twig', [
'socialPost' => $socialPost
]);
}
else throw $this->createNotFoundException('Post does not exist');
}
Other solution:
{% extends app.request.isXmlHttpRequest() ? 'frontend/clean.html.twig' : 'frontend/base.html.twig' %}
Use clean base template for ajax requests.