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

On create page, add default locale automatically #402

Open
sanderha opened this issue Apr 16, 2018 · 13 comments
Open

On create page, add default locale automatically #402

sanderha opened this issue Apr 16, 2018 · 13 comments

Comments

@sanderha
Copy link
Contributor

sanderha commented Apr 16, 2018

This issue is for when FluentFilteredExtension is enabled on SiteTree.

When creating a new page, it has no Locales by default. So even after publishing the page, it will not show up in frontend, unless a Locale is added.
Wouldnt it make sense to automatically add the global default domain to a newly created page? Then the user can always change it if they like.

I added this through an extension:

    public function onBeforeWrite()
    {
        // add default locale to newly create page automatically
        if (!$this->owner->isInDB() && !$this->owner->FilteredLocales()->exists()) {
            $default = DataObject::get_one(Locale::class, ["IsGlobalDefault" => 1]);
            $this->owner->FilteredLocales()->add($default);
        }
    }
@robbieaverill
Copy link
Contributor

@sanderha can you please provide the versions of SilverStripe and the fluent module you're using?

@sanderha
Copy link
Contributor Author

@robbieaverill SS 4.1 and fluent 4 :-)

@robbieaverill
Copy link
Contributor

Yeah this issue is somewhat related to https://github.com/tractorcow/silverstripe-fluent/issues/350 which we treated as a documentation issue.

This idea might be worth exploring though. What do you think @tractorcow?

@tractorcow
Copy link
Collaborator

The default locale used to mean a lot more in fluent 3.x than it does in 4.x. The new convention is that all locales are equal, and that there is no real concept of a "default". The only reason for keeping the default locale a flag is to assist with choosing the view locale in the frontend. I don't think that "assume this page is always visible in the default locale" is a good default to be honest.

@sanderha
Copy link
Contributor Author

@tractorcow I think this issue is mainly about FluentFilteredExtension. Without it, everything works fine. But if its on, every page is disabled by default, because they have no locales attached. IMO in this case its best to attach default locale on create so clients dont get confused

@tractorcow
Copy link
Collaborator

Should it be enabled for all pages by default?

@sanderha
Copy link
Contributor Author

@tractorcow I dont think FluentFilteredExtension should be on by default. I just think that if its on, the global default locale should be attached to all pages. Then clients can remove it if they want

@tractorcow
Copy link
Collaborator

Sorry, I mis-spoke.

I meant "should it be enabled for all locales by default?". That may be less destructive than requiring users to re-check locales.

@sanderha
Copy link
Contributor Author

Hmm yeah it probably should just enable all locales when creating a page. Thats also how Fluent 3 worked I believe (all locales were checked).

@tractorcow
Copy link
Collaborator

I think DataObject needs an onCreated extension point which is invoked only once for every model. then we could add the locale links there.

@RoyalPulp
Copy link
Contributor

Is there any progress on this?
For large projects it is a catastrophe to add this FluentFilterExtension to SiteTree later to live running Websites.
-> When you have many pages in all languages and your customer asks: "Is there a possibility to hide this page just in one language" - the moment you add the extension for SiteTree to the config, the whole website is "offline"/ 404 in all locales.
With SS3.x there has not been a problem with that.
All locales should be active by default!

This should better be a "hide locale" feature than a "add locale"

@sanderha
Copy link
Contributor Author

@RoyalPulp We've made a task that attaches locales to pages after the FluentFilteredExtension is added, which might help you out:
https://github.com/nobrainer-web/silverstripe-fluent-recipe/blob/master/src/BuildTasks/ToggleFilteredLocales.php

@tractorcow
Copy link
Collaborator

I might pick this up; Thanks @sanderha for that I'll look through your recipe later. :) It has some good ideas.

@tractorcow tractorcow self-assigned this Jul 28, 2019
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

4 participants