oc-easyspa-plugin icon indicating copy to clipboard operation
oc-easyspa-plugin copied to clipboard

components that are called by partials get treated as new layouts

Open Denoder opened this issue 7 years ago • 4 comments

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

Denoder avatar Sep 02 '18 19:09 Denoder

@Teranode what needs to be fixed / changed?

LukeTowers avatar Sep 02 '18 19:09 LukeTowers

@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;

Denoder avatar Sep 02 '18 20:09 Denoder

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.

Denoder avatar Sep 02 '18 20:09 Denoder

@LukeTowers this is as much as i could do: https://github.com/LukeTowers/oc-easyspa-plugin/pull/7

Denoder avatar Sep 03 '18 12:09 Denoder