WordPress.org

Ready to get started?Download WordPress

Forums

Contextual Related Posts
[resolved] CRP & QTRANSLATE (19 posts)

  1. fers
    Member
    Posted 1 year ago #

    Is there a way to make these two great plugins work together?
    CONTEXTUAL RELATED POSTS + QTRANSLATE

    Anyone succeeded at this?
    Post titles do get translated, however the title of Contextual Realated Posts widget does not
    :(

    http://wordpress.org/extend/plugins/contextual-related-posts/

  2. Ajay
    Member
    Plugin Author

    Posted 1 year ago #

    Fers, am not familiar with QTranslate. Is it just a simple plugin that creates a translation of all text on your blog?

    Is there something special that the plugin authors need to do for getting it compatible ?

  3. fers
    Member
    Posted 1 year ago #

    What Qtranslate does is to store each post's title and contents within wp's database in multiple languages, but under the same post id. Each text block is preceeded by a shortcode that "marks" the start and end of the translated string/text, then at the time of displaying the post in, let's say English, it filters the content leaving just the desired language visible. And all this works perfect with CRP. CRP shows the post titles in the correct language in the widget.

    It's only the widget TITLE the one that does not play well and does not get translated (instead it shows the full multilanguage string along with qtranslate's shortcodes). Weird!

  4. Ajay
    Member
    Plugin Author

    Posted 1 year ago #

    Am going to take a wild guess here, but it could possibly be because qTranslate isn't able to read the Title of the widget. Do you know if there is a specific piece of code / method that can be added to get qTranslate to detect this?

  5. fers
    Member
    Posted 1 year ago #

    No idea honestly, I will investigate a bit so that maybe we can sort this out. But it's got to be a trivial matter I hope :)

  6. Ajay
    Member
    Plugin Author

    Posted 1 year ago #

    Sounds good. If you figure out what code changes / links which I can read to understand this, let me know. I'll see what I can do.

    Do other widgets from plugins work fine for translation?

  7. fers
    Member
    Posted 1 year ago #

    Standard "Recent posts" plugin in twenty Ten gets its widgets title translated through qTranslate, for instance.
    Maybe this helps?
    http://www.qianqin.de/qtranslate/forum/viewtopic.php?f=3&t=294

  8. Ajay
    Member
    Plugin Author

    Posted 1 year ago #

    Can you try editing contextual-related-posts.php after line 344

    $title = apply_filters('widget_title', empty($instance['title']) ? strip_tags($crp_settings['title']) : $instance['title']);

    add:

    if(function_exists('qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage')) $title = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($title);

  9. fers
    Member
    Posted 1 year ago #

    Done. No effect unfortunately. Still getting

    [:en]Title[:es]Titulo

    as the output.

    :(

    By the way... Is it a "widget" properly speaking? Because CRP in fact inserts its output below the post content in my case. Not using it as a "widget" from the "widgets" menu in the WPtheme.

  10. fers
    Member
    Posted 1 year ago #

    Update. As I said before, I am not using the widget mode, but instead the option that injects CRP at the end of post content, and in this scenario, the bug exists. However, just for testing I also added CRP as a widget from the widgets menu in WP, and in this case it works flawlessly. The title of the widget displays only the correct language.

  11. Ajay
    Member
    Plugin Author

    Posted 1 year ago #

    Fers, was confused since you said Widget title in the earlier post. In this case, what you need to do is add the above code after line 79:

    if (empty($limit)) $limit = stripslashes($crp_settings['limit']);
  12. fers
    Member
    Posted 1 year ago #

    Hi Ajay, I'm REALLY sorry for the misleading info. :(

    Look, the line of code you just told me to add after line 79 is already there (in line 79!).
    Maybe you pasted line 79 itself in your last reply?

  13. fers
    Member
    Posted 1 year ago #

    Ajay, disregard my last email please. The code you told me to insert is the one in the previous email, if(function_exists('qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage')) ....

    So, added it after line 79, and still the title of the lest's call it "CRP Box" shows the multilingual string.

    Fers

  14. Ajay
    Member
    Plugin Author

    Posted 1 year ago #

    Fers that sounds great! Am assuming this fixes it well?

  15. fers
    Member
    Posted 1 year ago #

    No, it did not. The trick was somewhere else.
    At Line 98, I tried the following and yes, this cures the bug!

    if(!$is_widget) {

    if(function_exists('qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage')) $title = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($crp_settings['title']);
    $output .= (stripslashes($title));
    }

    My question now is, do you plan to insert this in a future update? Otherwise each time your plugin has a new version, the problem would reappear.

    Thanks!

  16. Ajay
    Member
    Plugin Author

    Posted 1 year ago #

    Fers, is this the only issue of compatibility between the two plugins?

    Am going to drop a line to Qtranslate's plugin developer and see what he has to say regarding this being missed out.

    Did you contact him about this?

  17. Ajay
    Member
    Plugin Author

    Posted 1 year ago #

    There might be a more universal solution to this if create a filter for the title and then you can write a function in your functions.php of your theme that will apply the filter.
    This will prevent you modifying the files.

    Instead of making the change you did earlier, replace line 90 of the latest version, add this:

    $title = apply_filters('crp_heading_title', $title);  // Apply filters so that this can be extended with custom functions
    if(!$is_widget) $output .= stripslashes($title);

    In your functions.php add:

    function crp_qtranslate($title) {
    if(function_exists('qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage')) $title = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($title);
    return $title;
    }
    add_filter('crp_heading_title', 'crp_qtranslate');

    Please backup before you make the changes, since am not sure if this will definitely yield the result.

  18. fers
    Member
    Posted 1 year ago #

    Perfect. Tried it and it works this way!
    Much more elegant and useful.

    Now the question is, will you apply this modification in your next release so that I don't have to patch the plugin everytime you upgrade?

    Thanks!

  19. Ajay
    Member
    Plugin Author

    Posted 1 year ago #

    Great! That's want I wanted to hear!
    I'll implement this in the next release.

    I'll mark this as resolved for now, but let me know if you have questions.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags