Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> For Hire
Author Message
rovshan
Hangin' Around



Joined: Nov 26, 2005
Posts: 40

PostPosted: Sun Sep 06, 2015 8:09 am Reply with quote

Dear All,
I need your advise to start new project.
Very important issue is that I have to create multi-langage site with several online services (by creating modules, blocks) with integration of responsive design, google map, paypal payment etc. which are the same for all languages.
It is clear that raven support multi-language issue but I need different solution.
I would like to achieve these points :

French version should have this address - french.domainname(.fr)
English version this address - enlish.domainname(.co.uk)

For each language site I should have:
1. common date base
2. common modules / blocks / themes
3. different mod_rewrite rules via .htaccess

I installed new version of raven nuke, but it works in different way => one site -> many languages

I kindly ask you to give me your advise to implement these requirements in very optimal way. Is it possible to use in this case ravennuke ? Thank you.
 
View user's profile Send private message
kguske
Site Admin



Joined: Jun 04, 2004
Posts: 6437

PostPosted: Sun Sep 06, 2015 9:35 pm Reply with quote

I use htaccess and modifications to the config file to support multiple sites using the same files (modules/blocks/themes) but with different databases. But in order to use different default languages, you'd need to do an override after reading the config table (where the default language is defined). Unfortunately, that would require modifications to mainfile - not trivial and not for the faint of heart.

_________________
I search, therefore I exist...
Only registered users can see links on this board! Get registered or login!
 
View user's profile Send private message
rovshan







PostPosted: Mon Sep 07, 2015 5:04 am Reply with quote

kguske, thank you for reply

Exact there are some not trivial modifications to do Smile
What I achieved is to separate and place the folders in different directories on the root of server, like this:

COMMON CORE DIRECTORY (on the server root) includes ravennuke folders:
abuse
blocks
classes
db
images
includes
language
modules
themes

In this case when I need to do any modification in modules and blocks, I will be able to do it once and use at all separated by domaine name language versions.

each domaine (language version) points to directory which includes :
.htaccess
admin folder
admin.php
cache
config.php
header.php
footer.php
mainfile.php
index.php
modules.php
public folder
rnconfig.php
rnlogs
robots.txt
ShortLinks folder
uploads folder

It works, but I did not check yet all rn functions.
It would be great to move in common core directory maximum files and folders from domaine directory.
What do you think about ? Is this a good way ? Which folders or files you suggest should be moved in common core directory?

I am not very strong coder Sad , so I would like to hire (to pay) the professional for this job.

Thank you for support.
 
kguske







PostPosted: Mon Sep 07, 2015 6:41 am Reply with quote

You might be able to accomplish the language override in your theme and keep all files common. You could use .htaccess to set an environment variable based on the domain:
Code:
SetEnvIf Host french\.domainname\.fr  RN_DOMAIN_CODE=fr

SetEnvIf Host ^domainname\.fr RN_DOMAIN_CODE=fr
SetEnvIf Host english\.domainname\.co\.uk RN_DOMAIN_CODE=uk
SetEnvIf Host ^domainname\.co\.uk RN_DOMAIN_CODE=uk

Then, in your config (if you want to use different databases, put this where the existing user, password, database and site are defined):
Code:
$rnDomainCode = isset($_SERVER['RN_DOMAIN_CODE']) ? $_SERVER['RN_DOMAIN_CODE'] : '';

if ($rnDomainCode=='uk') {
   $dbuname = 'domain_uk_user';
   $dbpass = 'domain_uk_pass';
   $dbname = 'domain_uk_db';
   $sitekey = 'xxxxxxukxxxxx12345';
} else {
   $dbuname = 'domain_fr_user';
   $dbpass = 'domain_fr_pass';
   $dbname = 'domain_fr_db';
   $sitekey = 'xxxxxxfrxxxxx12345';
}

You could do something like that in the theme.php file to override the language:
Code:
<?php

if (!defined('NUKE_FILE')) die ('You can\'t access this file directly...');
$rnDomainCode = isset($_SERVER['RN_DOMAIN_CODE']) ? $_SERVER['RN_DOMAIN_CODE'] : '';
global $language;
if ($rnDomainCode=='uk') {
   $language='english';
} else {
   $language='french';
}

I suggest adding this code to the theme for these reasons:
- Your theme is probably already customized
- Your may have additional language customization in your theme
- The theme is loaded before other files, but after the config and after security checks
- You won't have to customize standard RN files, so you'll probably be able to upgrade without making additional changes (probably, unless the language variable name changes, the theme is loaded at a different time, or, as will likely be the case, there are major changes to the theme).

However, I'm not sure how this will affect the user's language if the user is logged in. Let's say a French speaker chooses to log into the UK domain. I would test that, and before changing your production server, test on a local platform and make backups of the files you change before turning it on in case you need to revert.
 
rovshan







PostPosted: Wed Sep 09, 2015 4:39 am Reply with quote

Thank you for suggestion. I verified this idea with fresh installation of RN.
Just one problem : $language variable is fixed accordingly the domain name language version and takes correct value, but $lang variable in mainfile file still take value which indicated in config !? I just checked cookie - lang value is same as in config?!
I have to add $lang in your code and moved this code in mainfile :
if ($rnDomainCode=='uk') {
$language='english';
$lang='english';
} else {
$language='french';
$lang='french';
}

It works. Smile

Here is the code from my mainfile, which works:

$sitename = $nuke_config['sitename'];
//$nukeurl = $nuke_config['nukeurl'];
$site_logo = $nuke_config['site_logo'];
........
$backend_title = $nuke_config['backend_title'];
$backend_language = $nuke_config['backend_language'];
//$language = $nuke_config['language'];
$locale = $nuke_config['locale'];
..........
$pagetitle = '';

$rnDomainCode = isset($_SERVER['RN_DOMAIN_CODE']) ? $_SERVER['RN_DOMAIN_CODE'] : '';
global $language;
if ($rnDomainCode=='en') {
$language='english';
$lang='english';
$nukeurl = 'en.domainname.fr';
}
if ($rnDomainCode=='fr') {
$language='french';
$lang='french';
$nukeurl = 'fr.domainname.fr';
}

/**
* GFX Code v1.0.0
*/
include_once NUKE_INCLUDE_DIR . 'gfx_check.php';

if (!defined('FORUM_ADMIN')) {
$ThemeSel = get_theme();
include_once 'themes/' . $ThemeSel . '/theme.php';
if (($multilingual == 1) AND isset($newlang) AND !stristr($newlang,'.')) {
$newlang = check_html($newlang, 'nohtml');
if (file_exists('language/lang-' . $newlang . '.php')) {
setcookie('lang', $newlang, time() + 31536000);
include_once 'language/lang-' . $newlang . '.php';
$currentlang = $newlang;
} else {
setcookie('lang', $language, time() + 31536000);
include_once 'language/lang-' . $language . '.php';
$currentlang = $language;
}
} elseif (($multilingual == 1) AND isset($lang) AND !stristr($lang, '.')) {
$lang = check_html($lang, 'nohtml');
if (file_exists('language/lang-' . $lang . '.php')) {
setcookie('lang', $lang, time() + 31536000);
include_once 'language/lang-' . $lang . '.php';
$currentlang = $lang;
} else {
setcookie('lang', $language, time() + 31536000);
include_once 'language/lang-' . $language . '.php';
$currentlang = $language;
}
} else {
setcookie('lang', $language, time() + 31536000);
include_once 'language/lang-' . $language . '.php';
$currentlang = $language;
}
}

Thank you for your ideas Smile looking for your comments
 
kguske







PostPosted: Wed Sep 09, 2015 5:08 am Reply with quote

Glad it works without having to duplicate files!

You might consider moving the custom code to your theme file (make sure both variables are global). That way, you can upgrade mainfile without having to redo your changes.

Cheers!
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> For Hire

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©