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

Content from redirector pages appears in search results but isn't editable in the CMS #67

Open
madmatt opened this issue Jan 20, 2022 · 2 comments

Comments

@madmatt
Copy link
Member

madmatt commented Jan 20, 2022

Scenario:

  1. Create a standard page, add some content into $Content, save and publish. Content is indexed into Elastic - this is fine.
  2. Change the page type to RedirectorPage. Content is now hidden in the CMS (as the Content field is hidden) but content is not removed from Elastic as it still exists on SiteTree.

This only happens with the $Content field if it's indexed, because that field is on SiteTree, not a sub-class that gets changed.

It's probably enough to treat this as a special case, rather than doing anything more complicated, and just block the indexing of the Content field if the source_class is RedirectorPage.

@madmatt madmatt changed the title Content from redirector pages appears but isn't editable in the CMS Content from redirector pages appears in search results but isn't editable in the CMS Jan 20, 2022
@madmatt
Copy link
Member Author

madmatt commented Jan 20, 2022

Worth noting this would also affect any fields on the pages where the page type is changed between two pages that have slightly different hierarchy but a common ancestor.

For example, if you have SiteTree -> Page -> LandingPage and SiteTree -> Page -> OtherPage and on OtherPage you hide a bunch of fields from either SiteTree or Page, then those fields may still end up being indexed. I don't know of a good way around that beyond forcing users to decide for every single page type what fields should be indexed.

@n8-dev
Copy link

n8-dev commented Mar 20, 2023

For anyone still stumbling across this, a current adhoc solution is to create a RedirectorPageExtension
With the following code.

    public function onBeforeWrite()
    {
        if ($this->getOwner()->ShowInSearch) {
            $this->getOwner()->ShowInSearch = 0;
        }
    }

Since this is a core Silverstripe page type, perhaps this solution could be added to this repo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants