14

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 all available sites for an entry with {% set supportedSites = entry.getSupportedSites %} This will return you an array of all supported sites for the entry. {...


12

Update for Craft 3 Craft 3 includes native support for multi-site installation. Here's a link to the official docs and here's a link to another question with more resources. Old answer for Craft 1 & 2 Credit to @LukeHolder for the original answer, but here's a bit more detailed and technical answer. Note, this might not be possible on all hosts. ...


10

Yes, it is possible to have a Craft install on multiple domains and subdomains as long as you only access the control panel from a single domain and you only have a single installation of craft that all the domains and subdomains use. The limitation is all domains would be using the same url router and content - although for multi language content having ...


8

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'), '@baseUrl' => getenv('CRAFTENV_BASE_URL'), ], (or whatever/however you want to set them). These aliases can be used in sites’ Base URL settings, ...


6

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 official docs on Sites in Craft 3.


6

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.


6

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 have its own index.php file and .htaccess file (if using Apache). Assuming you used the craftcms/craft project as a starting point, update the define('...


5

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 point and save it as en_custom.php. Then add a new key/value pair 'en_custom' => 'My Custom Country' to the languages array (line 205 ff.), which is ...


5

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#currentsite <ul> {% for site in currentSite.group.sites %} <li class="{% if currentSite.id == site.id %} is-active{% endif %}"> {% set url = ...


5

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 set currentEntrySiteB = craft.entries.id(entry.id).site(2).one() If you want to search for disabled entries (for example in CP templates) for other sites you ...


5

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 to parse it: {{ alias(craft.app.sites.primarySite.baseUrl) }} Altertatively, if you need to link to a sub-page of the primary site (not just its Base URL), ...


4

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.


4

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.app.language }} Handle: {{ craft.app.sites.currentSite.handle }} I'm not entirely positive how to loop the sites in the template but you can get a sites object ...


4

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 %} In Craft 3, craft.app in a template basically gives you access to everything in the services namespace. Adding craft.app.sites opens up all of the methods in ...


4

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


4

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 same page. {% set element = (category ?? entry ?? null) %} <ul> <li><a href="{{ siteSwitcher('english', element) }}">English</a>&...


4

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 - Site A - language NL - Site A - language Fr SiteGroup B - Site B - language Fr Let's imagine your Site A - language Fr is your primary site. So it ...


4

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 CurrentSite depending on your url not on the location of the file. Second: make sure to insert an array with aliases in your config/general.php I'll show a "...


4

Use aliases, by first defining them in your general.php: 'dev' => [ 'siteUrl' => [ 'default' => 'https://site.test', 'korean' => 'https://site.test/ko', 'brazil' => 'https://site.test/pt' ], 'devMode' => true, 'aliases' => [ '@baseUrl' => 'http://site.test', ...


4

{% 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 certain site in your language switcher {% set entryInOtherSite = craft.entries.id(entry.id).siteId(2).one() %} {{ entry.getUrl() }} I'm not sure why you even ...


4

{{ siteUrl }} should do the trick for you.


4

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


4

The parameter is called siteId <input type="hidden" name="siteId" value="{{ currentSite.id }}">


4

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 Control Panel, try to reset the order of your sites in there (drag/drop using the little handle to the right of each site row), it should stop them showing up in a ...


4

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 the right slug relative to current URL #} {% switch currentSite.id %} {# siteA.com #} {% case 1 %} {% redirect '/my-404-slug' %} {# siteB.com #} {% ...


3

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-domain-live-preview


3

No you can't. In Craft's early days, they had a MSM-like (ala ExpressionEngine) feature, but they eventually removed because it overcomplicated the system. You will have to run a unique craft install per domain. However, these Craft installs can at the very least share the same craft/app folder: http://buildwithcraft.com/help/sharing-craft-files


3

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 looks like that's not what you need and your subdomains are more part of one and the same site. Even with multiple root and template folders you could still ...


3

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 entry in German, the Asset selector modal will only display Assets assigned to the German locale. And if you were viewing the entry in Dutch, it would only show ...


3

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 Query()) ->select(['id', 'groupId', 'name', 'handle', 'language', 'primary', 'hasUrls', 'baseUrl', 'sortOrder']) ->from(['{{%sites}}']); }...


Only top voted, non community-wiki answers of a minimum length are eligible