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"> </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?