Comments (5)
Hi @Josua2012 ,
The main reasons for having this function, are:
- Separate persistant storage for current locale, meaning that you can view the site and edit it without the locale being inherited across the two browser windows
- Prevent filtered objects from being filtered in the CMS
I will admit ignorance to the specifics of your module, but I can add a hook into this function for you to override it as necessary in your controller. Will update you shortly.
from silverstripe-fluent.
I've allowed you to work around this with tractorcow@7dbf340.
Now you can implement isFrontend
in your controller to manually specify if this is a frontend controller or not. You can also add this as an extension to your controller, if you don't want to hard code it into your module.
Test cases and documentation added.
public static function is_frontend($ignoreController = false) {
// No controller - Possibly pre-route phase, so check URL
if($ignoreController || !Controller::has_curr()) {
// $_SERVER['REQUEST_URI'] indeterminatelys lead with '/', so trim here
$base = preg_quote(ltrim(Director::baseURL(), '/'), '/');
return !preg_match('/^(\/)?'.$base.'admin(\/|$)/i', $_SERVER['REQUEST_URI']);
}
// Check if controller is aware of its own role
$controller = Controller::curr();
if($controller->hasMethod('isFrontend')) return $controller->isFrontend();
// Default to return false for any CMS controller
return !($controller instanceof AdminRootController)
&& !($controller instanceof LeftAndMain);
}
from silverstripe-fluent.
Also, don't forget to follow the instructions under https://github.com/tractorcow/silverstripe-fluent#using-custom-controllers
If you are using a custom controller you need to add the FluentContentController extension.
from silverstripe-fluent.
Don't worry if that missing-controller line is met... there is a bit of pre-request handing detection that's done in order to best-guess the user locale, just in case the handling controller doesn't correctly install the locale (as Security controller does, due to it not calling onBeforeInit on its nested Page_Controller).
If you add the FluentContentController extension, your custom controller will correctly set the locale from the admin-view session field.
from silverstripe-fluent.
I had to make an extension with isFrontend function for that controller (CreateEcommerceVariations).
Now the detection works correctly.
Thanks Damian
from silverstripe-fluent.
Related Issues (20)
- Cannot fetch translations when table names include spaces. HOT 1
- Feature request: Locale and Domain confguration outside the DB / better in yml File HOT 4
- GraphQL 4 query response weirdness with fresh fluent install HOT 6
- Making Widgets translateable in Fluent 5+
- Clear localisation from selected locale HOT 1
- v6 - Performance issues when loading treeview HOT 5
- Double x-default link tag on home page HOT 1
- Incorrect format used for page link when parent page is unpublished HOT 2
- CMSPreview should be considered "frontend" HOT 7
- SilverStripe 5 compatibility HOT 6
- Asset admin edit form actions HOT 4
- Bug: CMS Language selector disappearing HOT 8
- Message is slightly misleading when new page is created
- How should the ORM interact with state and `withState()` in particular? HOT 3
- HomepageLink with the $AbsoluteBaseURL template variable HOT 8
- Cookie “FluentLocale_CMS” has been rejected because it is already expired.
- Breaking unit tests on 6 HOT 2
- Fluent breaks silverstripe's fulltext filter (not SearchForm!)
- Locale detection not working
- Fluent v6 - Pages in ModelAdmin Localizing in another Locale throws error HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from silverstripe-fluent.