Back to ProBlog Support

rino28174
rino28174

Hello. I've been using ProBlog plugin on my web site around 3 months, and now I decided to write blog posts in two different language using Translate plugin. Post's title and summery by proBlogList are rendered correctly in the list mode, but the post itself is not. Looks like all the Markdown markups are lost in a single post displaying mode.

Here's an example:

What did I missed? Thanks in advance for taking some time.

ChadStrat
ChadStrat

I think this is going to take some experimentation. So first, I don't see how the summary in the list view would be working either? It's not technically translated that I can see. /problog/components/bloglist/default.htm , I would think we would need to pipe that for translation? So

{{ post.excerpt }}

should be

{{ post.excerpt|_ }}

(that's not an L that's a 'pipe') And then also

{{ post.content_html|_|raw }}

(that's 'pipe', underscore,'pipe', raw)

Secondly the post view, /problog/components/blogpost/default.htm I believe whould be similar. The issue I am not sure about, is the order of piping on multiple pipe twig functions, and also in respect to twig functions that call back to the plugin file.

So I am hoping you can try editing some of these and playing around with adding '|_' to the twig markup and help figure this out. This would be helpful as I don't speak multiple languages or have any real way to test.

ChadStrat

rino28174
rino28174

I'm digging into codes and database. So far I noticed it seems like it's relating the database table for Markdown version.

In ProBlog database, content contains HTML rendered version, while content_markdown contains the original Markdown version. function beforeSave stores content (which is the textarea of Content tab) as content_markdown because the textarea contains Markdown version. Then, assign HTML version of content by using formatHtml function. So database table radiantweb_blog_posts contains both HTML rendered (content) and Markdown (content_markdown) versions correctly. Since excerpt is written in raw text only, it stores correctly as well.

On the other hand, database table rainlab_translate_messages contains HTML version only. I don't know the reason but I guess we also need to swap content/content_markdown before saving them into database by Translate plugin.

P. S. function afterFetch should be like this? content_markdown contains Markdown version, which should be stored in content while editing.

    public function afterFetch()
    {   
        if (ProblogSettingsModel::get('markdownMode', false)) {
            $this->content = $this->content_markdown;
        }
    }
rino28174
rino28174

No, changing afterFetch affects when not only editing but rendering the post.

rino28174
rino28174

Off topic: I found that possibly a bug in clonePost. beforeSave will be called after clone before saving. In beforeSave content_markdown is replaced by content, so the line for content should look like this:

$new_post->content = (ProblogSettingsModel::get('markdownMode', false)) ? $post->content_markdown : $post->content;
rino28174
rino28174

OK. I found a workaround.

Patch

Add following code at the end of public function onRun() of components/Post.php:

            if($this->page['embedly']){
                $this->addJs('/plugins/radiantweb/problog/assets/js/jquery.embedly.js');
                $this->addJs('/plugins/radiantweb/problog/assets/js/embedly.js');
            }

+           if ($this->post && ProblogSettingsModel::get('markdownMode', false)) {
+               $this->post->content = $this->post->formatHtml($this->post->content);
+           }

According to this support forum's posts, I also did following modification for models/Post.php:

use \October\Rain\Database\Traits\Validation;
public function afterFetch()
{
//    if (ProblogSettingsModel::get('markdownMode', false)) {
//        $this->content_markdown = $this->content;
//    }
}

And changed clonePost as mentioned above.

Details

The cause of the problem, which happens Translate plugin is used while markdownMode enabled, might be the way to use of post's content and content_markdown. content stores HTML converted version of content_markdown, unless the post is loaded to create/edit in Content tab of ProBlog backend. While editing the post, content stores Markdown version. When it will be saved (using Update button), beforeSave() is invoked, and do two things: store Markdown version to content_markdown and convert it to store HTML version in content. At the same time Translate plugin saves translated version of content to separated database table. The problem is, beforeSave runs after Translate plugin runs, so Translate's database table only stores Markdown version of the corresponding post. So the workaround is for each onRun, always convert from Markdown (content_markdown) to HTML(content).

How do you think?

Last updated

rino28174
rino28174

Patch above wasn't complete solution. Some posts (very long) are shown only the first a few segments. Still investigating.

1-7 of 7