0

I've just recently started working with Pimcore in my work and I'm now on a project consisting of three languages each in their seperate tree.

Today the sites URL is my-site.com/LANGUAGE/sub-page For example: my-site.com/se/about

But what we would want to have is LANGUAGE.my-site.com/sub-page. For example: se.my-site.com/about

I've tried using the static route tool but couldn't get it to work at all and my knowledge of pimcore is somewhat limited. I found the Pimcore documentation on static routes (HERE) but I didn't find it all that helpful.

Do I need a controller and an action to handle this. Or can it be done simply with the static route tool?

EDIT: I've tried to use the "domain tool" from when you right-click a site. But this only works if I change in the hosts file of the computer by setting 127.0.0.1 to be connected to us.MYSITE.com. Won't this be an issue for when the site goes live? Since the users don't have my hosts file. That is why I went down the road of static routes.

Mattias
  • 387
  • 1
  • 5
  • 17
  • I wrote an answer but deleted it because I was unsure if it completely fits your requirements. Do you want different document-trees for different content or is this solely about setting the right language for one document tree by using subdomains? – GNi33 May 08 '15 at 14:51
  • I might have explained it poorly. I have my site setup with a root node which has three sub-sites, one for each language. So each language will be it's separate tree. This works and everything. The thing is that I don't want the URL to be ROOT/LANGUAGE/Sub-page but instead want it to be LANGUAGE.ROOT/Sub-page, for example: us.MYPAGE.com/about instead of MYPAGE.com/us/about See edit in original post. Comment restrictions. – Mattias May 11 '15 at 05:42
  • okay, I undeleted my answer then, the "Sites"-feature is definitely how you want to approach this, all you need to take care of is a correct host-file on the server for your subdomains. The user does not need to have these files, as they are only important for correctly handling incoming requests. Your current setup is locally, I think? – GNi33 May 11 '15 at 06:53

2 Answers2

4

There is the "Sites" - feature in Pimcore that lets you do this.

The documentation page describes how you set this up, but I'll explain it quickly:

You basically set up your document tree like this, creating a usual document for each of your languages:

Document Tree

After this, all you need to do is change these documents into "Sites" (picture taken from the docs) by right clicking and clicking "Use as site":

Multisites in Pimcore

As you can see, the popup now offers you a field where you can add and edit new domain-names, as well as subdomains. Depending on what version of Pimcore you are using, this may look a little different, the documentation shows an older version.

This is probably what you will see in a newer version after creating the site, right clicking it and going to "Edit Site":

Pimcore Site options

This offers a slightly nicer way to manage your domains and additional ones, you don't have to add additional domains by editing a comma seperated list, now every line in the textarea resembles a domain. So what you need to do is enter your language-subdomain as main domain.

The site now acts exactly like the "Home" - Site at the Document-Root and the Site - feature acts similar to a static route you would set up.

Now what you need to do additionally is set your server up to route the subdomain to your pimcore - folder, this answer will probably help you out. There won't be a problem with the host - files as you mentioned, as they are stored on the server anyhow, the user does not need to have these, so using the "Sites"-feature is definitely the way to approach this problem over the static route - tool.

Community
  • 1
  • 1
GNi33
  • 4,459
  • 2
  • 31
  • 44
1

Common approach to multilingual sites is to create separate document trees for each language and setup content-master documents (known as content inheritance feature). Then for each additional language you can create "site" and setup different subdomain.

- home (main launguage, main domain)
  - subpage_1
  - subpage_2
  - de (site = de.example.com)
    - subpage_1 (master-document = /home/subpage_1)
    - subpage_2 (master-document = /home/subpage_2)
Rafal Gałka
  • 1,022
  • 1
  • 10
  • 16
  • I think you misunderstood me. I have my website setup with different "sub-sites" for each language. However I want to change the URL to access them. To the LANGUAGE.MYSITE.com/sub-page format instead of MYSITE.com/LANGUAGE/sub-page – Mattias May 11 '15 at 05:48