2017-04-08 63 views
0

Im新的symfony3和我需要一點幫助,我有一個時間軸網頁,其中包含帖子,每個帖子都有一個評論欄,所以爲了做到這一點,我已經安裝了FOSCommentBundle,遵循所有步驟本文檔https://github.com/FriendsOfSymfony/FOSCommentBundle/blob/master/Resources/doc/index.md的,然後我跟FOSUserBundle整合它,我的確在async.html.twig文件中的以下變化:如何使用FOSCommentBundle

<div id="fos_comment_thread">#comments</div> 

<script type="text/javascript"> 

    // thread id 
    var fos_comment_thread_id = 'pub'; 

    // api base url to use for initial requests 
    var fos_comment_thread_api_base_url = 'localhost/Outdoors5/web/app_dev.php/threads'; 

    // Snippet for asynchronously loading the comments 
    (function() { 
     var fos_comment_script = document.createElement('script'); 
     fos_comment_script.async = true; 
     fos_comment_script.src = '{{ asset('bundles/foscomment/js/comments.js') }}'; 
     fos_comment_script.type = 'text/javascript'; 

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

但最終我得到了我如何使用這個很迷茫,我試圖理解和搜索tuto,但沒有運氣。 這是我的看法

  <section id="timeline"> 


       {% for publication in publications %} 

<div id="result"></div> 
        <div class="page-content page-app page-profil " > 
          <div class="profil-content"> 
           <div class="row"> 
             <div class="row"> 

               <div class="item item-comment"> 
                <div class="user"> 
                 <h5 class="name">{{ publication.idProfil.nom }}</h5> 
                 <div class="clearfix"> 
                  <p class="time">{% if publication.dateCreation %}{{ publication.dateCreation|date('Y-m-d') }}{% endif %}</p> 
                 </div> 
                 <div class="comment"> 
                  <p class="c-primary m-b-0"><strong>{{ publication.texte }}</strong></p> 
                 </div> 
                </div> 
                <div class="more"> 
                 <div class="row"> 
                  <div class="col-sm-4 like"> 
                   <i class="fa fa-heart"></i> Like 
                  </div> 
                  <div class="col-sm-4 more-comments"> 
                   <div class="comment-number"> 
                    <i class="icon-bubble"></i> Comments<span class="pull-right badge badge-dark">3</span> 
                   </div> 
                  </div> 
                  <div class="col-sm-4 more-share"> 
                   <i class="icon-share"></i> Share 
                  </div> 
                 </div> 
                 <div class="row comments"> 
                  <div class="col-sm-12"> 
                   <ul> 
                    <li class="clearfix"> 
                     <div class="clearfix"> 
                      <div class="info"> 
                       <div class="name"><strong class="primary-font"></strong></div> 
                       <div class="date"></div> 
                      </div> 

                      <p> 

                       comment 1 

                      </p> 
                     </div> 
                    </li> 
                    <li></li> 
                   </ul> 
                  </div> 
                 </div> 
                 <div class="row share"> 
                  <div class="share-facebook"> 
                   <i class="fa fa-facebook"></i> 
                  </div> 
                  <div class="share-twitter"> 
                   <i class="fa fa-twitter"></i> 
                  </div> 
                  <div class="share-google"> 
                   <i class="fa fa-google-plus"></i> 
                  </div> 
                 </div> 
                </div> 
               </div> 
             </div> 
           </div> 
          </div> 
        </div> 

       {% endfor %} 
      </section> 

你能爲我指向正確的方向? 謝謝

+0

說明你已經能夠使FOSCommentBundle以下工作從我的答案的建議? – Kwadz

回答

0

有沒有必要修改async.html.twig。你只需要在你的樹枝視圖中添加以下代碼:

{% include 'FOSCommentBundle:Thread:async.html.twig' with {'id': 'foo'} %} 

綜上所述,執行下列步驟後:

對於FOSU​​serBundle整合,你只需要擴展Comment類爲Step 6: Integration with FOSUserBundle