Support » Plugin: Multisite Language Switcher » New feature: joining comments from all linked posts

  • Hi to author,

    I would like to display all the comments from the linked translations of the displayed post. Do you have any plans to implement this functionality?

    If not, could you help me with implementing this – of course I would send you the code so you could include it into to the plugin.
    I’m planning to get the $comments separately and then put them as an argument into function wp_list_comments().
    To get the $comments, I need the code to get a list of blog_id-s + post_id-s.

    Unfortunately I’m not very fond of OOP in PHP. Could you tell me where in your code you implemented constructing a list of translation of your blog? So: in goes the post_id, out comes the list of blog_id + post_id of the translations.

    Best wishes, D.

    http://wordpress.org/plugins/multisite-language-switcher/

Viewing 12 replies - 1 through 12 (of 12 total)
  • +1 for this feature.

    @DSmidge please, let us know what solution you took, if any 😉

    Plugin Author Dennis Ploetner

    (@realloc)

    I’m not sure if the plugin should do this too. But let me think about it or let’s discuss about it here so I can understand why this is necessary.

    You can do the following to get a list of the translations for a post:

    $blogs  = MslsBlogCollection::instance();
    $mydata = MslsOptions::create();
    $posts  = array();
    foreach ( $blogs->get_objects() as $blog ) {
        if ( $blog->userblog_id != $blogs->get_current_blog_id() ) {
            switch_to_blog( $blog->userblog_id );
            $language = $blog->get_language();
            if ( 'MslsOptions' != get_class( $mydata ) && !$mydata->has_value( $language ) ) {
                restore_current_blog();
                continue;
            }
            $posts[] = $mydata->$language;
            restore_current_blog();
        }
    }
    print_r( $posts );

    Hope this helps!

    Now, I use qTranslate for my blog. A certain post is written in two languages, and all the comments are displayed no matter in which language are you viewing the post. The comments are usually in English.

    I would now like to try to duplicate that behavior in MLS, because qTranslate is SLOOOW (too much hook calls) and not actively developed anymore. Of course, if I manage to go through with this, I will post the instructions how to migrate from qTranslate to MLS.

    Thanks for your answer, @realloc. I will try your code these days and report back how it works.

    Meanwhile, we can discuss if it is needed or not. I would say if you have blogs in different languages comments should be joined because they are commenting the same article (although in different languages). I am not sure how good is it for SEO since one would have duplicate content (comments) for all post in different languages.
    In any case, I saw this in some of the top multilingual blogs which use WordPress.

    Another question, if this should be implemented as a hack to database so you write/read comments to/from the same database no matter what blog it is. Or, they should be joined in the output (which seems a better idea one can always turn on/off). The question then if one will be able to reply to all comments from different languages, probably this functionality will be blocked.

    Plugin Author Dennis Ploetner

    (@realloc)

    @davydov-denis

    In my opinion it seems not really a task for the switcher since all contents are separated and just “related” with the help of an additional array in the option_table of a blog. Mixing the contents together seems to be another thing. But – of course – it can be done much easier with the help of the plugin.

    Consider also the following code if you want to mix the comments of a post and its translations together.

    $blogs    = MslsBlogCollection::instance();
    $mydata   = MslsOptions::create();
    $comments = array();
    foreach ( $blogs->get_objects() as $blog ) {
        if ( $blog->userblog_id != $blogs->get_current_blog_id() ) {
            switch_to_blog( $blog->userblog_id );
            $language = $blog->get_language();
            if ( 'MslsOptions' != get_class( $mydata ) && !$mydata->has_value( $language ) ) {
                restore_current_blog();
                continue;
            }
            $comments = array_merge(
                $comments,
                get_comments( array( 'post_id' => $mydata->$language ) )
            );
            restore_current_blog();
        }
    }
    print_r( $comments );

    Cheers,
    Dennis.

    As davydov-denis already mentioned – the problem with joining comments will be the wrong Reply links for comments from other blogs and the comments hierarchy would be broken.

    So I see three possible solutions:
    – displaying comments form all joined posts – breaks Reply (could be difficult to fix) and comments hierarchy (even more difficult to fix);
    – storing (+ modify, + delete) all comments in all blogs – all contents get duplicated, all operations (modify/delete, mark as spam, etc.) must also work with duplicated comments; huge problem with hierarchy if comment_id-s are not the same on all blogs;
    – storing all comments only in first blog – storing/displaying comments and Reply/Edit buttons must be fixed to work with 1st blog;
    I wrote this without any analysis. Did I miss something?

    I’m leaning towards 3rd solution. What is your opinion?

    I forgot about correcting comment_count on posts.

    Plugin Author Dennis Ploetner

    (@realloc)

    I personally would not mix all comments together. The code above is just for giving you some idea how you can resolve this special issue. There is no (at least I believe that) advantage for SEO. It is just double content.

    One advantage – when you decide to use the Multisite Language Switcher – is that you can always change your mind and deactivate the plugin. It would not change completely your site. You would just loose its additional functionality.

    So there is no dependency. The switcher does not change the table-layout of the database. The plugin stores only the relations of the various contents in the options-tables.

    In my opinion a functionality like “comment-mixing” – which seems to have also some remarkable complexity – creates just problems and would lower the performance.

    @realloc

    i agree with you. At best this might be kind of add-on plugin which does the functionality, but i would not be putting this into the plugin itself.

    For myself i would probably stick with separated comments. The reason is that if one uses some plugins to rework comments (e.g. JetPack’s comments) i guess one would need to hack it as well to show comments from the main blog. That becomes a kind of nightmare.

    Although among different solutions proposed by @DSmidge i think the third one is the lesser evil.

    As a user, i really do appreciate that the plugin only adds relationships between posts in Network and thus if it is deactivated or not supported in 10 years – no harm is done. Only cross links are gone. That was one of the reason i never tried qTranslate or WPML.

    Plugin Author Dennis Ploetner

    (@realloc)

    Yes. I think also that an add-on could be an interesting possibility. There are other functionalities too which I test just as add-ons. For example:

    https://github.com/lloc/msls-importer
    https://github.com/lloc/MslsMenu

    I commited an initial version of the plugin/extention:
    http://wordpress.org/plugins/msls-comments/

    Description:
    All comments posted on translation-joined pages gets stored into first blog. Then all comments are displayed on all translation-joined posts.
    THIS PLUGIN IS NOT YET READY FOR PRODUCTION USE (read FAQ)

    Installation:
    Requires changes in theme’s comments.php file (read Installation on plugin’s homepage).

    To do:
    * notifications are always send in the first blog’s language
    * page count does not work on translated posts
    * probably some glitches, because the plugin has not been thoroughly tested yet

    Plugin Author Dennis Ploetner

    (@realloc)

    Very good. I will look into this in the next days.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘New feature: joining comments from all linked posts’ is closed to new replies.