I have a theme with two RTL and LTR direction versions. I want to load RTL version for RTL languages (such as Persian) and LTR version for non-RTL versions. What’s the “BEST” way to this in Yii framework ?
I have a theme with two RTL and LTR direction versions. I want to load RTL version for RTL languages (such as Persian) and LTR version for non-RTL versions. What’s the “BEST” way to this in Yii framework ?
HI
simply you can check the Direction or language and then put such code in header part of "protected\views\layouts\main.php"
<html <?php if(Yii::app()->language == 'fa') echo "dir='rtl'"; ?>
xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo Yii::app()->language; ?>"
lang="<?php echo Yii::app()->language; ?>">
For CSS:
if Yii::app()->language =='en'
{
// load LTR CSS
...
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/main.css" />
...
}
else {
// load RTL CSS
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/main-rtl.css" />
}
[b]one more thing!
Could you please share me your theme (theme with two RTL and LTR direction versions)
i need it.[/b]
In my case, I use a somewhat-customized bidirectional 12-column 960.gs. Here’s a possible theming with Arabic / French (easy to switch to Farsi / English):
[list=1]
[*]layouts/main.php:
<!doctype html>
<?php $baseUrl = Yii::app()->request->baseUrl; ?>
<html <?php echo (Yii::app()->language === 'ar' ? 'dir="rtl" lang="ar"' : 'dir="ltr" lang="fr"');?>>
<head>
<meta charset="utf-8">
<title><?php echo CHtml::encode($this->pageTitle); ?></title>
<meta name="description" content="">
<meta name="keywords" content="">
<meta http-equiv="X-UA-Compatible" content="chrome=1"><!-- for Google ChromeFrame this one breaks W3C HTML5 validation, there are easy workarounds, just google it -->
<meta name="google-site-verification" content="">
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="<?php echo $baseUrl; ?>/css/reset.css">
<link rel="stylesheet" type="text/css" href="<?php echo $baseUrl . '/css/960-12' . (Yii::app()->language === 'ar' ? '-rtl' : '') . '.css';?>">
<link rel="stylesheet" type="text/css" href="<?php echo $assets; ?>/css/yourCSS.css"><!-- of course replace it with your CSS file -->
<link rel="shortcut icon" href="<?php echo $baseUrl; ?>/favicon.ico" type="image/x-icon">
</head>
<body<?php if(Yii::app()->language === 'ar') echo ' class="rtl"';?>>
<div id="glo_c" class="c12">
<header>
<div id="logo" class="g5">
…
</div>
<nav class="g7">
…
</nav>
</header>
<?php echo $content; ?>
<footer>
…
</footer>
</div><!-- end of #glo_c -->
</body>
</html>
[*]column2.php:
<?php $this->beginContent('//layouts/main'); ?>
<nav class="g12">
<?php if (isset($this->breadcrumbs)) {
$this->widget('zii.widgets.CBreadcrumbs', array(
'links'=>$this->breadcrumbs,
));
} ?>
</nav>
<aside class="g3">
<?php $this->beginWidget('zii.widgets.CPortlet', array(
'title'=>'Operations',
)); ?>
<?php $this->widget('zii.widgets.CMenu', array(
'items' => $this->menu,
'encodeLabel' => false,
'htmlOptions' => array('class'=>'operations'),
)); ?>
<?php $this->endWidget(); ?>
</aside>
<article class="g9">
<?php echo $content; ?>
</article>
<?php $this->endContent(); ?>
[/list]
And here are attached my 960-12.css, 960-12-rtl.css, and Eric Meyer-based reset.css, in addition to a fully-commented 960-12-commented.css (LTR version)