FriendsOfSymfony / FOSCommentBundle

Threaded comments for Symfony
http://friendsofsymfony.github.com/
MIT License
462 stars 230 forks source link

I dont see the comments, problem with the script #150

Closed Chrysweel closed 12 years ago

Chrysweel commented 12 years ago

I did all steps, but I can't see the script of comments. But in my source code of page is the code of script.

// URI identifier for the thread comments
var fos_comment_thread_id = '/xxx/web/app_dev.php/api/threads/104/comments';

// Snippet for asynchronously loading the comments
(function() {
    var fos_comment_script = document.createElement('script');
    fos_comment_script.async = true;
    fos_comment_script.src = '/xxx/web/app_dev.php/js/35a8e64_comments_1.js';
    fos_comment_script.type = 'text/javascript';

    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(fos_comment_script);
})();

The number 104 is a integer.( the id of my post) I included jquery-1.7.1.min.js

What am I doing wrong? Any idea? Thanks.

asm89 commented 12 years ago

Do you see errors in your javascript console?

What do you see on the url: /xxx/web/app_dev.php/api/threads/e.id/comments

Chrysweel commented 12 years ago

asm89 thanks by to reply.

In mi web console I see a call strange: URL of one request: http://localhost/xxx/web/app_dev.php/threads104/comments?permalink=http%253A%252F%252Flocalhost%252Fxxx%252Fweb%252Fapp_dev.php%252page

And on the url: /xxx/web/app_dev.php/api/threads/104/comments " [Semantical Error] line 0, col 101 near 'ancestors AS': Error: Class Application\ApplicationBundle\Entity\Comment has no field or association named ancestors. "

I seen that when I entry on page which include 'FOSCommentBundle:Thread:async.html.twig' is created in my database one thread.

My class comment extends of FOS\CommentBundle\Entity\Comment.

I don't know that is wrong. Any idea?

Chrysweel commented 12 years ago

Help me please!! Any idea?

merk commented 12 years ago

Can you please post your entire configuration including entities, config.yml, the controller you're trying to include it in.

Chrysweel commented 12 years ago

Ok merk.

First my classIndex.html.twig:

{% extends 'ApplicationBundle::layout.html.twig' %} {% block center %} {% include 'FOSCommentBundle:Thread:async.html.twig' with{'id': e.id} %} {% endblock %}

my layout.html.twig:

(...) {% block javascripts %} < script type="text/javascript" src="{{ asset('js/jquery-1.7.1.min.js')}}"> < script type="text/javascript" src="{{ asset('js/jquery.color-RGBa-patch.js')}}"> < script type="text/javascript" src="{{ asset('js/example.js')}}"> {% endblock %}

My config.yml

imports:

- { resource: parameters.ini }
- { resource: security.yml }
- { resource: services.yml }

parameters:
security.acl.permission.map.class: Sonata\AdminBundle\Security\Acl\Permission\AdminPermissionMap sonata.admin.security.mask.builder.class: Sonata\AdminBundle\Security\Acl\Permission\MaskBuilder

framework:

translator:  {fallback: es}
secret:          %secret%
charset:         UTF-8
router:          { resource: "%kernel.root_dir%/config/routing.yml" }
form:            true
csrf_protection: true
validation:      { enable_annotations: true }
templating:      { engines: ['twig', 'php'] } #assets_version: SomeVersionScheme
session:
    default_locale: %locale%
    auto_start:     true

twig:

debug:            %kernel.debug%
strict_variables: %kernel.debug%

assetic:

debug:          %kernel.debug%
use_controller: false
filters:
    cssrewrite: ~
    yui_css:
          jar: usr/share/yui-compressor/yui-compressor.jar
    yui_js:
          jar: usr/share/yui-compressor/yui-compressor.jar

doctrine:

dbal:
    default_connection: default
    driver:   %database_driver%
    host:     %database_host%
    port:     %database_port%
    dbname:   %database_name%
    user:     %database_user%
    password: %database_password%
    charset:  UTF8

orm:
    auto_generate_proxy_classes: %kernel.debug%
    #auto_mapping: true
    entity_managers:
        default:
            mappings:
                ApplicationSonataMediaBundle: ~
                FOSUserBundle: ~
                SonataUserBundle: ~
                ApplicationBundle: ~
                LocalBundle: ~
                SonataMediaBundle: ~

swiftmailer:

transport: %mailer_transport%
host:      %mailer_host%
username:  %mailer_user%
password:  %mailer_password%

jms_security_extra:

secure_controllers:  true
secure_all_services: false

jms_serializer:

handlers:

    object_based: false
    datetime:
        format: < ISO8601 (Y-m-dTH:i:s)>
        default_timezone: none
    array_collection: true
    form_error: true
    constraint_violation: true
property_naming:
    separator: _
    lower_case: true

metadata:
    cache: file
    debug: %kernel.debug%
    file_cache:
        dir: %kernel.cache_dir%/serializer
    directories:
        any-name:
            namespace_prefix: Application\ApplicationBundle
            path: @ApplicationBundle/Resources/config/serializer

fos_user:

db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: Application\ApplicationBundle\Entity\User

group: 
   group_class: Application\ApplicationBundle\Entity\Group

fos_comment

fos_comment:

db_driver: orm class: model: comment: Application\ApplicationBundle\Entity\Comment thread: Application\ApplicationBundle\Entity\Thread

My Comment.php

<?php

namespace Application\ApplicationBundle\Entity;

use Doctrine\ORM\Mapping as ORM; use FOS\CommentBundle\Entity\Comment as BaseComment;

/**

Sorry by the fomat, but I don't know to do for write all equal.

merk commented 12 years ago

You dont have auto mapping enabled, and do not import FOSCommentBundle mappings.

Chrysweel commented 12 years ago

I have modified my config.yml (...) doctrine: orm:

auto_mapping: true
   # entity_managers:
    #    default:
     #       mappings:
     #           ApplicationSonataMediaBundle: ~
      #          FOSUserBundle: ~
       #         SonataUserBundle: ~
        #        ApplicationBundle: ~
         #       LocalBundle: ~
          #      SonataMediaBundle: ~

(...) But don't work.

Chrysweel commented 12 years ago

Reopen the issue please!

merk commented 12 years ago

Cleared your cache?

What error is reported now?

Chrysweel commented 12 years ago

Yes I cleared my cache with: sudo rm -r app/cache/dev The same, the comment don't see so I cant write comment in my post.

And in my console web, I see the following error: URL of the request: http://localhost/application/web/app_dev.php/api/threads/102/comments?permalink=http%253A%252F%252Flocalhost%252Fapplication%252Fweb%252Fapp_dev.php%252Fpost%252Ftitle-post

Méthod of request:
GET

status of code:
HTTP/1.0 500 Internal Server Error
Chrysweel commented 12 years ago

Any idea?? I had installed the FOSCommentBundle which work it correctly a month ago,And now that I reinstalled the FOSCommentBundle with the FOSRestBUndle and the JMSSecurity... and I have this problem. Help me please!

asm89 commented 12 years ago

I need more information than a 500 Internal Server Error to see what your problem is.

merk commented 12 years ago

You have to update your schema when changing mapping settings.

Chrysweel commented 12 years ago

asm89 I don´t have more information!

Finally it works !!!! THANKS merk, I update schema with: sudo php app/console doctrine:schema:update --force and now I see the comments.

But something really strange is happening, when I see a post, I don´t see the comments but if I do CTRL+F5 then it works.I see other post and the comments not are, but I do CTRL+F5 then I see the comments.

Why does this happen?

THANK YOU SO MUCH!!!

Chrysweel commented 12 years ago

Ok I have solved it also. This problem ocurred because the call to comment.js was before of the call to jquery-1.7.1.min.js.

I hope help other people with this problem.

thank you very much!! Merk and asm89 thanks! ; )

asm89 commented 12 years ago

Glad you worked it out. I'll close the issue now.

MSoni05 commented 6 years ago

hey @merk is it necessary to include default comment.js in layout ,as i already have in web/foscumment/js my console showing

http://localhost/symfony/MySymPro/web/app_dev.php/api/threads/foo/comments?permalink=http%253A%252F%252Flocalhost%252Fsymfony%252FMySymPro%252Fweb%252Fapp_dev.php%252Fprofile%252F 500 ..some jquey error