Comments (8)
Thank you SO MUCH @daftspunk
We are getting a lot of the multisite feature - we're using it to host two different e-commerce sites with different everything. We had to make some utilities for the Twig templates in mail templates, and we had to do some other things to separate users, because we were not comfortable turning on Mulltiiste for users or email templates. Is that wise?
I'll let you know how it goes with the next upgrade.
from october.
Hi @ccamarillo
Each site uses its own file cache, configured in our plugin's Plugin.php
Can you share the code used here? It is possible that this code is not running for the combiner URLs and would cause this outcome.
from october.
Here's where we specify our two different caches for the two different sites:
Plugin.php
public function boot()
{
$siteCode = \OakleySI\OakleySI\Classes\Multisite::getSiteCode();
// CACHE
if ($siteCode == 'ess-direct') {
$cacheDriver = 'ess';
} else {
$cacheDriver = 'oakley';
}
// Once you have the cacheDriver, set the configuration
config(['cache.default' => $cacheDriver]);
...
}
And then the cache.php config:
return [
'stores' => [
'ess' => [
'driver' => 'file',
'path' => storage_path('framework/cache/ess'),
],
'oakley' => [
'driver' => 'file',
'path' => storage_path('framework/cache/oakley'),
],
...
]
]
We've established a workaround - avoid using the combiner to load our scripts and stylesheets - load one at a time. Thanks @daftspunk
from october.
The reason we have two caches is because with just one, one site would overwrite the files and the other site's files would disappear from the cache.
from october.
Thanks, may I ask what are the contents of the OakleySI\OakleySI\Classes\Multisite::getSiteCode()
method?
from october.
public static function getSiteCode() {
$installedOnDomains = env('INSTALLED_ON_DOMAINS', false);
$user = \Auth::getUser();
if ($user) {
if ($user->customer_group === null) {
return self::getSiteCodeFromUrl();
}
$siteCode = $user->customer_group->code;
return $siteCode;
} else if (!$installedOnDomains) {
// get first segment after domain name
$url = \Request::url();
$urlParts = explode('/', $url);
if (count($urlParts) < 4) {
return 'ess-direct'; // fall back to this site if no code exists in url segment / such as when running in console or admin
} else {
$siteCode = $urlParts[3];
return $siteCode;
}
} else {
return self::getSiteCodeFromUrl();
}
}
We are using OFFLINE Mall customer groups to allow users to access one site or another. If they are logged in, we look at the OFFLINE Mall customer group to identify what site they have access to. If they come to the site and are not logged in, we determine which cache to use based on the URL segments or domain. Customer groups and Sites share codes... that is how I am managing access to these sites. We will redirect from one site to another if the user tries to access the wrong site based off their customer group.
I suppose if there is some other method we could use to determine which cache to use, I'm all ears on that. There may be a mismatch between what site id is actually loading and what I am determining here? Thank you.
from october.
Also, here is getSiteCodeFromUrl():
private static function getSiteCodeFromUrl() {
// get the beginning of the url, including protocol and domain name
$url = \Request::root();
$site = \System\Models\SiteDefinition::where('app_url', $url)->first();
if (!$site) {
return 'ess-direct'; // fall back to this in admin
}
$siteCode = $site->code;
return $siteCode;
}
from october.
In v3.6, we've added the ability to enable multisite in the system combiner:
// config/multisite.php
'features' => [
'system_asset_combiner' => true, // β set to true
// ...
],
Once enabled, a different cache key is used for each site, and the active site is set when the combiner first loads to ensure custom configuration will also apply.
Hopefully this will resolve the original issue by itself.
To preserve the current solution, the boot method should hook the site.changed
event when the change becomes available later in the app lifecycle.
public function boot()
{
Event::listen('site.changed', function($id) {
$siteCode = \Site::getSiteCodeFromContext();
// CACHE
if ($siteCode == 'ess-direct') {
$cacheDriver = 'ess';
} else {
$cacheDriver = 'oakley';
}
// Once you have the cacheDriver, set the configuration
config(['cache.default' => $cacheDriver]);
});
}
v3.6 should be released soon.
I hope this helps!
from october.
Related Issues (20)
- Use "merge keys" / "block definitions" for grouped repeaters HOT 2
- Page in Backend List is not applied correctly after filterChange HOT 1
- Default Value for Balloon-Selector not applied if the field is added via addTabFields()
- Returning False in model.beforeβ¦() Still Flashes Success HOT 2
- Implement select For type: taglist HOT 5
- Call to a member function getKey() on null HOT 1
- Unable to show Relation features in backend forms when nested HOT 1
- Watch data-list-checked-request without user button click HOT 3
- October 3.6 - InvalidArgumentException: View [lang.strings.mail_form_submit] not found. HOT 3
- October 3.6 - Update error HOT 4
- Missing background image on login page HOT 1
- Navigation items visible without permissions HOT 2
- Error when sending e-mail HOT 2
- In Safari, list filters are not aligned correctly. HOT 1
- Wrong Order for displayMode: sidebar on Small Screens HOT 1
- Group Scope for Parent/Nested Relations HOT 1
- Class 'Str' not found HOT 2
- Call to undefined method October\Rain\Database\Relations\AttachMany::getRelatedKeyName() HOT 1
- Error exporting models using csv_custom file format HOT 4
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 october.