Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibility to have multiple threads in one page #235

Closed
wants to merge 4 commits into from
Closed

Possibility to have multiple threads in one page #235

wants to merge 4 commits into from

Conversation

ahilles107
Copy link

If you want have multiple threads on one page add the following code at a desired place in the template to load the comments

{% include 'FOSCommentBundle:Thread:async.html.twig' with {'thread_container': '.comments-box'} %}

Your page must have:

<div class="comments-box" data-thread-id="my_unique_thread_id_1"></div>
<div class="comments-box" data-thread-id="my_unique_thread_id_2"></div>

fixes #232

* var fos_comment_thread_id = 'a_unique_identifier_for_the_thread';
* // Set the thread id if you want comments to be loaded via ajax (url to thread comments api)
* // Your thread container must have data-thread-id attribute with requested thread id.
* <div class="thread-contaner" data-thread-id="my_unique_thread_id"></div>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo here

@asm89
Copy link
Member

asm89 commented Jul 14, 2012

Is this PR still a WIP? I can't imagine this code already works 100%. There are a lot of missing changes. Apart from that the current JS isn't designed for this (imo) and I'm not sure if I want to support this natively in the bundle with the current JS implementation.

@ahilles107
Copy link
Author

@asm89 for me all is working god. About what missing changes you talking?

@ahilles107
Copy link
Author

@asm89 - can you answer on my question?

@merk
Copy link
Member

merk commented Jul 24, 2012

If we're going to end up doing something to natively support this, I would prefer to change FOS_COMMENT into an reusable class where you call something along the lines of this:

var thread = new FOS_COMMENT(thread_container, { url: url }); 

@mablae
Copy link
Contributor

mablae commented Sep 4, 2012

Hello,

I am facing the same problem: I want to include many threads on one page. (A bit like Facebook does with FriendStream).

So we should work on this feature, there is definitly a usecase. @asm89 could you please ping back what issues with this PR you are seeing (missing updates)?

cheers mablae

@merk
Copy link
Member

merk commented Sep 4, 2012

I have plans to redo the javascript to support multiple threads, it will just take some time. I dont think this approach is the best one, I would prefer to move to a more object instance approach.

@mablae
Copy link
Contributor

mablae commented Sep 5, 2012

Sounds great!

@tarjei
Copy link
Contributor

tarjei commented Jan 29, 2013

You may have to have a plan for how you register thread.permalink if you have multiple threads on the same page...

@merk
Copy link
Member

merk commented Jan 29, 2013

A good point. My current code changes dont take into account using different permalinks. Will address this next time I work on it (and it is almost ready to merge into master!)

@RossOliver
Copy link

Hi, has there been any progress with this? I'm desperate for this functionality!

Many thanks.

@merk
Copy link
Member

merk commented Feb 11, 2013

There has been progress but it has stalled for about a month now. I have what I consider to be the 3.0.0-alpha1 branch on my repository, but there is still more work to be done before pushing it. It contains large BC breaks and most users of FOSCommentBundle have probably not constrained their version to 2.0.*..

merk/FOSCommentBundle@master...new-javascript

@lerminou
Copy link

lerminou commented Mar 9, 2013

Hi, is it now fixed ? i really want to implement this functionnality.

@cordoval
Copy link

@lerminou he has it in this new-javascript branch meaning it has not been released yet, we are still in 2.0.x

👶

@tarjei
Copy link
Contributor

tarjei commented Aug 7, 2013

@merk: Any news on the 3.0.0 branch?

@merk
Copy link
Member

merk commented Aug 9, 2013

No sorry, I havent had time to dedicate to tidying it up. I still dont know when I will get a day to sort it out and release it.

The current state is at https://github.com/merk/FOSCommentBundle/tree/new-javascript

@qpleple
Copy link

qpleple commented May 23, 2014

any update on this?

@qpleple
Copy link

qpleple commented May 23, 2014

For those interested, I was able to have multiple threads on the same page using the original version of the bundle (without modifying any files):

<div class="fos_comment_thread" data-thread="{{ thread.id }}">
    {% include 'FOSCommentBundle:Thread:comments.html.twig' with {
        'comments': comments,
        'thread': thread
    } %}
</div>
  • before loading comments.js, change the thread container selector:
var fos_comment_thread_container = $('.fos_comment_thread');

It works because, in comments.js, event listeners are intialized by
thread_container.on(...) which works even if thread_container refers to multiple elements.

@tdaryani01
Copy link

any update on this?

@fundup
Copy link

fundup commented Jul 15, 2015

Thanks @ahilles107 I did as you suggested. I spent time to understand and apply so the solution for those who are interested (I copy and include comment.js due to I don't use assetic):

https://gist.github.com/fundup/eb38be3a13d5581da3d1

@cjuhong
Copy link

cjuhong commented Sep 17, 2015

@fundup
Is the variable fos_comment_thread_container used by any fucntions?

@fundup
Copy link

fundup commented Sep 17, 2015

It seems to be DOM selector to insert comments so I think it's used

@cjuhong
Copy link

cjuhong commented Sep 17, 2015

@fundup

I copy the code you shared, but I can't see any comment textarea box.

All the thread_containers are empty divs.

@cjuhong
Copy link

cjuhong commented Sep 17, 2015

@ahilles107

I can't see any comment textarea box. All the thread_containers are empty divs.

@cjuhong
Copy link

cjuhong commented Sep 17, 2015

@fundup @ahilles107

Hi,
following your instruction, the function getThreadComments() is never called to init the comment box UI.

@cjuhong
Copy link

cjuhong commented Sep 18, 2015

Hi,

I found a hack solution for requirement:

adding a iframe tag and the src attribute point to a route which load the

jquery
and

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

@XWB XWB closed this Jul 20, 2016
@flavienaudin
Copy link

Hi,
The issue is closed but it doesn't seem to be fixed. Is there any update about this feature ?
Thanks

@ksn135
Copy link

ksn135 commented Oct 26, 2018

For those interested, I was able to have multiple threads on the same page using the original version
@qpleple thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Several comments boxes on page