15
votes
Accepted
Craft 3 language switcher
The concept of localization has changed in Craft 3, there are not only locales anymore - now you have different sites and site groups.
Example without multisite - only different locals
You can get ...
- 19.6k
9
votes
Accepted
How do I get the primary site URL?
You can output the primary site’s Base URL like this:
{{ craft.app.sites.primarySite.baseUrl }}
(craft.app.sites maps to craft\services\Sites.)
If your Base URL begins with an alias, you will need ...
- 34k
8
votes
Accepted
Craft 3: how can I set dynamic Base URL in sites setting?
So as of Craft CMS 3 RC7, they added a new alias() Twig function.
So what you can do is something like this in your general.php:
'aliases' => [
'@basePath' => getenv('CRAFTENV_BASE_PATH'),
...
- 11.3k
6
votes
Accepted
Specifying administrators for localized sites?
Yes. you can:
Here I created a User group which has only access to the english part of the content.
As you can see these are checkboxes. So you can grant access to multiple languages at once.
- 3,734
6
votes
Multi-site setup in Craft3
You can also check out the free video on it here: Using Craft CMS 3 Multi-site
Multi-site has changed as of Craft 3 RC11. It now requires much less config outside of the control panel. See the ...
- 924
6
votes
Accepted
Craft 3 Multi-site with no "default" site
This can be done in 3 main steps.
1. Get the site subdirectories working
First just get the /en/ and /es/ subdirectory working:
Create en/ and es/ subfolders in your webroot
Each subfolder should ...
- 34k
5
votes
How to change the locals name in Localized Sites
You could add new pseudo localization files to Craft craft/app/framework/i18n/data/ and rename (translate) the name of your "language" and other things in these files.
I'd use en.php as a starting ...
- 36k
5
votes
Craft 3 language switcher
Little addition with a fallback to the homepage and check if entry exist.
currentSite is a global variable already defined in craft3 https://docs.craftcms.com/v3/templating/global-variables.html#...
- 308
5
votes
Accepted
Craft 3 multisite - are entries accessible between sites?
Yes it is. Just include the site id of the the site in your query
set siteId = 2
set entries = craft.entries.section('foo').site(siteId).all()
if you want to get the current entry for another site
...
- 19.6k
5
votes
Accepted
Can you get the baseUrl for site by handle or id?
{% set site = craft.app.getSites().getSiteById(1) %}
{% set site = craft.app.getSites().getSiteByHandle('handle') %}
{{ site.baseUrl }}
But I would rather suggest you to grab the entries URL for a ...
- 19.6k
5
votes
Accepted
How to order Sites
I've seen that before, if you look at the sites table in your DB, you'll see that a few sites might have their sortOrder set to 1.
If you go to Settings → Sites → [the offending group] in your ...
- 7,340
4
votes
Accepted
Multi-site setup in Craft3
Have you watched the Craft Hangout?
Managing Multiple Sites in Craft 3 – Sites and Localization
Might be of use if you haven't. You'll need about an hour free to view it.
- 2,475
4
votes
Accepted
Loop through all sites in multisite installation
If you want to do this purely from a template, then something like this:
{% set sites = craft.app.sites.getAllSites() %}
{% for site in sites %}
<li>{{ site.name }}</li>
{% endfor %}
...
- 67k
4
votes
Loop through all sites in multisite installation
Nikolay,
As I responded in the slack, I will respond here in case anyone else has this question.
In the template you can access this information like so:
SiteUrl: {{ siteUrl }}
Langauge: {{ craft....
- 632
4
votes
Accepted
Craft 3: with Base URL of site set up using @web alias, how to display the original URL in Twig templates?
So luckily for us, Brandon recently added the alias() Twig function. It should show up in Craft CMS 3 RC7. You can see the discussion about it here: https://github.com/craftcms/cms/issues/2327
- 11.3k
4
votes
Craft 3 language switcher
As of today, Site Switcher is now available in the plugin store! *
It was called "Language Link" in Craft 2, but the premise is the same... It allows you to switch between sites while staying on the ...
- 23.8k
4
votes
Craft 3 multi-lingual multi-sites setup with shared assets
You could create 2 site groups. One group for site A and one group for site B.
Sitegroup A will contain contain 2 sites, the other one only one site.
Your setup will look like this
SiteGroup A
-...
- 19.6k
4
votes
Accepted
Craft 3 Multi Language Setup
First of all you should remove all "language" subfolders from your web directory because your web server will route directly in those instead of your default web/index.php. Craft will determinate the ...
- 19.6k
4
votes
Craft 3 Multi Language Setup
Use aliases, by first defining them in your general.php:
'dev' => [
'siteUrl' => [
'default' => 'https://site.test',
'korean' => 'https://site.test/ko',
...
- 85
4
votes
4
votes
Accepted
Can two sites use the same channel, but have unique entries?
There is a light switch field in your section settings with the label "propagate entries across all sites". Just turn it off and your entries will be unique
- 19.6k
4
votes
Accepted
How to save entry to the current site from the front end?
The parameter is called siteId
<input type="hidden" name="siteId" value="{{ currentSite.id }}">
- 19.6k
4
votes
Accepted
How to route 404 errors for multi-site Craft?
I pondered this for a while, and then did this, which will direct us to specific entries (not templates, I don't want to create more of those):
{# We need a unique 404 for each site - just take us to ...
- 592
4
votes
Accepted
Displaying one site's content in another site (Craft 3 Multi-site)
I figured it out!
In Section settings > Propagation Method, you must choose 'Save entries to all sites enabled for this section', or, if you're using site groups, choose the appropriate group. This ...
- 592
4
votes
Accepted
Is it possible to localize Freeform fields and labels?
You can render the fields by your own and use the twig translate filter and do it with translation files. But I think there is no way to do it via the CP currently.
- 144
4
votes
Accepted
How do you insert the site name into a default asset path?
Try using {site.handle} instead of {{currentSite.handle}} and it should work ok.
- 328
3
votes
Accepted
Craft 3: how can I set an ordered list of all sites, and set a display name different from the site name?
If you would use a custom plugin you can create this function in your (I know it's deprecated but I don't know a better name) PluginVariable
public function createSiteQuery(): Query
{
return (new ...
- 19.6k
3
votes
Accepted
Two domains - single install - Live Preview works only on one
In order to get Live Preview to work across different subdomains on a single install, you'll need to setup a few extra things as outlined in this support article: https://craftcms.com/support/cross-...
- 67k
3
votes
Accepted
Site set up with mutiple sub domains
The approach you described is interesting and should actually work. Separate root folders would allow you to define the template folders individually (→ see Ben's answer on how to set this up), but it ...
- 36k
3
votes
Assets, Multi Locale and 'Target Locale'
The "Target Locale" setting under the Asset field's settings is referring to which locale do you want to select assets in. When it's set to "Same as source", then, for example, if you're viewing an ...
- 67k
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
multi-site × 164craft3 × 65
localization × 48
multi-domain × 20
assets × 10
multi-environment × 9
templating × 7
sites × 7
plugin-development × 6
entries × 6
users × 6
entry × 6
config × 6
live-preview × 6
control-panel × 5
routing × 5
globals × 5
language × 4
craft4 × 4
categories × 3
sections × 3
modules × 3
deployment × 3
graphql × 3
siteurl × 3