oc-easyspa-plugin
oc-easyspa-plugin copied to clipboard
components that are called by partials get treated as new layouts
Whenver a component is called in the CMS with the partial in it, it gets treated as a new layout:
{% component 'componentName::partial' %}
this is problematic if i want to use the same component but a different partial for it on a different page
@Teranode what needs to be fixed / changed?
@LukeTowers was doing some testing, and it seems it mostly has to do with this section in EasySPA.php:
if ($pageContents) {
// Render the partials to be updated
$partials = [];
if (!empty(input('refreshPartials'))) {
$refreshPartials = explode('&', input('refreshPartials'));
foreach ($refreshPartials as $partial) {
list($partialPath, $selector) = explode(':', $partial);
$partials[$selector] = $this->controller->renderPartial($partialPath);
}
}
$result = array_merge($result, $partials, [
'#layout-main' => $pageContents,
'X_EASYSPA_CHANGED_ASSETS' => json_encode($this->getChangedAssets($currentAssets, $this->controller->getAssetPaths())),
]);
} else {
$result['X_EASYSPA_RENDERED_CONTENTS'] = $fullResult;
}
its get's set in -> $result['X_EASYSPA_RENDERED_CONTENTS'] = $fullResult;
Also i have a suggestion, instead of having to have users forced to use easyspa-container, make a property where they can define a ID to use for refreshing.
@LukeTowers this is as much as i could do: https://github.com/LukeTowers/oc-easyspa-plugin/pull/7