Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Referencing a page in Subsite Virtual Page fails if you have to navigate to deeper sitetree level #412

Closed
torleif opened this issue Apr 30, 2019 · 4 comments

Comments

@torleif
Copy link
Contributor

torleif commented Apr 30, 2019

Steps to reproduce:

  1. create a new subsite virtual page

  2. change to another subsite with a large number of pages

  3. attempt to link to a page where it triggers an ajax reload

This is what is displayed in the SubsitesTreeDropdownField:

output2

This is likely the same issue as #337, only this one only gets triggered when trying to load more json for the SubsitesTreeDropdownField.

The json url then returns a 302 redirect which redirects to the page the browser is trying to download the json from:

output1

and in the console of the browser

output3

We have a temporary fix in place which forces any request with the GET parameter from the SubsitesTreeDropdownField to load the sitetree json, regardless of what subsite it's on. This is the code we use:

config.yml

SilverStripe\Admin\LeftAndMain:
  extensions:
    - OP\OPLeftAndMainSubsites

OPLeftAndMainSubsites.php

<?php

namespace OP;
use SilverStripe\Subsites\Extensions\LeftAndMainSubsites;
use SilverStripe\CMS\Controllers\CMSPageEditController;
use SilverStripe\Control\Controller;
use SilverStripe\Core\Config\Config;

/**
 * 
 * if the user is attempting to load the SubsitesTreeDropdownField json, we force
 * the global subsite to avoid any 302 redirects
 *
 * @author torleifw
 */
class OPLeftAndMainSubsites extends LeftAndMainSubsites {
    
    public function onBeforeInit()
    {
        $request = Controller::curr()->getRequest();
        if($request->getVar('CopyContentFromID_SubsiteID') !== null) {
            Config::inst()->set(CMSPageEditController::class, 'treats_subsite_0_as_global', true);
        }
        return parent::onBeforeInit();
    }
}

This is not the best fix. ideally the fix would be in SubsiteMenuExtension, and not relying on checking GET variables to trigger not redirecting the browser to the subsite you want to load the json from.

@robbieaverill
Copy link
Contributor

@torleif I'm not sure I can reproduce this issue. What do you define as "a large number of pages"?

@torleif
Copy link
Contributor Author

torleif commented Jun 1, 2019

@robbieaverill large enough to trigger an ajax update of the SubsitesTreeDropdownField

@robbieaverill
Copy link
Contributor

Presumably this is related to what you set TreeDropdownField.node_threshold_total to?

@torleif
Copy link
Contributor Author

torleif commented Mar 15, 2021

This looks to be resolved with the new tree selector field - i tried reproducing it but it seems to be ok now.

@torleif torleif closed this as completed Mar 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants