0

scenario

I want to manage a multi language site without using any add-ons. I’m successful in managing all content from single channel, single field set & single template by using conditional statements. I’m able to switch between two languages (English & Arabic).

Now i want URL structure like http://example.com/language_parameter/channel_name/module_name/param1/param2/param3

I failed to place language variable before channel name. I tried to alter htaccess file and few other hacks in core files but i couldn’t make the URL structure. Please guide me to achieve the desired URL structure

I’ve used stash to share variables (current language chosen) across templates and write conditional statements to decide what to show.

my .htaccess is

<IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /

        # Removes index.php from ExpressionEngine URLs
        #RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
        #RewriteCond %{REQUEST_URI} !/system/.* [NC]
        #RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]

         # Directs all EE web requests through the site index file
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ /ee_file/index.php/en|ar/$1 [L]

</IfModule>

Now

http://localhost:81/ee_file/index.php/about is able to retrieve {home_video}

{exp:channel:entries channel="home" limit="1"}
            <iframe  src="{home_video}" allowfullscreen></iframe>
 {/exp:channel:entries}

where as http://localhost:81/ee_file/index.php/en/about is not able to retrieve home's variable

I couldn't figure out how to use template routes in placing language variable before channel name in url.

  • Can't you set the language on domain level? You can have a default domain and a language subdomain, like domain.tld and en.domain.tld; or different TLDs for every language. – Robson Sobral Dec 29 '15 at 13:14
  • Sorry, We are using same domain for all languages. – krishna Dec 30 '15 at 5:02
0

On setting Template Routes

Template Routes

Though i couldn't apply any rules successfully, timely solution I found was to write conditionals like below in each template

{exp:channel:entries channel="prize_categories" }              
     {if "{segment_1}" == "en"}  {prize_en}
     {if:elseif "{segment_1}" == "ar"}  {prize_ar} 
     {/if}
{/exp:channel:entries}

I wrote a common template for header links like

<a href="/ee_file/index.php/{segment_1}/home"> Home </a> | <a href="/ee_file/index.php/{segment_1}/about"> About </a>

Please suggest me any other better solution

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.