Jump to content

language name after branch name in url


Gideon So
 Share

Recommended Posts

Hi,

i have two branches in the page tree as the following:

home

 -branch 1

   --page 1

   --page 2

 -branch 2

   --page 3

   --page 4

I have two languages enabled in the home page "lang1 and lang2"

The url generated is http://mysite.com/lang1/branch1/page1/

I want to have the url generated as http://mysite.com/branch1/lang1/page1/

Any hints are welcome.

Gideon

Link to comment
Share on other sites

Check this out my friend:

https://processwire.com/docs/tutorials/how-to-use-url-segments/

It's basically a way to not follow the routing of the page tree, so you can make up any possible route, and prepare your template's code for it, imagine this exist in the template file branch.php:

<?php

if($page->urlSegment1 == "es"){
	$user->language = $languages->get('es');
	// field output will be in spanish!
}elseif($page->urlSemgent1 == "en"){
	$user->language = $languages->get('en');
	// fields will output in english!
}

I'm just not sure how multilang works without the root language segment.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...