0

I've created a plugin that can add different content (text, map, etc.). I have registered Snippet in the plugin.

Plugin.php

...
public function registerComponents() {
    return [
        'Author\Contents\Components\Text' => 'textContent'
    ];
}

public function registerPageSnippets() {
    return [
        'Author\Contents\Components\Text' => 'textContent'
    ];
}
...

I created a text type component that created two properties (contentID [selector of existing text content], showTitle [selector, true or false]).

components/Text.php

...
public function defineProperties() {
    return [
        "contentId" => [
            "title" => "Select content",
            "type" => "dropdown",
            "placeholder" => "Please select a content..."
        ],
        "showTitle" => [
            "title" => "Show content title",
            "type" => "dropdown"
        ]
    ];
}

public function getContentIdOptions() {
    return Texts::orderBy("title")->lists("title", "id");
}

public function getShowTitleOptions() {
    return [
        "hide" => "No",
        "show" => "Yes"
    ];
}
...
public function onRender() {
    $this->contentData = $this->page["contentData"] = Texts::find($this->property("contentId"));

    foreach ($this->getProperties() as $key => $value) {
        $this->page[$key] = $value;
    }
}

components/text/default.htm

{{ showTitle }}
{{ __SELF__ }}

<div class="row">
    <div class="col-12">
        {{ contentData.content|raw }}
    </div>
</div>

When I try to insert a snippet to a page (in Static Pages plugin), it works perfectly. However, if I change the code snippet settings (for example, I change the showTitle property value from true to false), the content does not appear in the front-end page. If I change anything compared to the created state, the content will disappear. Even if that property is not included in the code.

If I do not modify the property used when inserting, it generates html. However, if I change, I see this in the inspector:

<figure data-component="Author\Contents\Components\Text" data-inspector-id="inspectorid-984837527907" data-property-contentid="6" data-property-showtitle="show" data-snippet="textContent">&nbsp;</figure>

Interestingly, the snippet of the Rjgallery plugin does not work, it does not load the content either.

EDIT

If I wait for a few minutes after the change, the changes will take effect. Probably a cache... How to take shorter time?

What is the reason of this?

  • Are you using the latest versions of the plugins? There was an issue last year in regards to using the Pages plugin with the Translate plugin which caused the cache to not update automatically – LukeTowers Feb 27 '18 at 04:49
  • @LukeTowers I have 2 languages(english and france) on my website and cache is still not updating automatically for only france language in latest build of 437. it is updating automatically for english language only. I have the pages plugin with translate plugin installed. For now I need to clear the cache manually to reflect the changes. – Zakir hussain Aug 12 '18 at 06:45
  • https://github.com/rainlab/translate-plugin/blob/master/Plugin.php#L91-L100 are the lines that are supposed to update the cache keys appropriately for the different languages, I would start by looking there to see if the keys are getting properly modified in the different languages. – LukeTowers Aug 12 '18 at 16:16

0 Answers0