2

I use opencart I want to load stylesheet-rtl.css when language is ar and stylesheet.css when language is en

i tried this and some others i found in internet but it doesn't work ?

<?php if($direction == "rtl"){?>
    <link href="catalog/view/theme/tt_palora1/stylesheet/style.css" rel="stylesheet">
<?php } else { ?>
    <link href="catalog/view/theme/tt_palora1/stylesheet/stylesheet.css" rel="stylesheet">
<?php }?>

any help please ?

Martin Zeitler
  • 1
  • 19
  • 155
  • 216
anton
  • 58
  • 7

2 Answers2

2

There is a direction variable in header.php:

$data['direction'] = $this->language->get('direction');

You can use it in your view file, edit this file:

catalog\view\theme\your-theme\template\common\header.twig

Find:

<link href="catalog/view/theme/your-theme/stylesheet/stylesheet.css" rel="stylesheet">

Replace it with:

{% if direction == 'rtl' %}
    <link href="catalog/view/theme/your-theme/stylesheet/stylesheet-rtl.css" rel="stylesheet">
{% else %}
    <link href="catalog/view/theme/your-theme/stylesheet/stylesheet.css" rel="stylesheet">
{% endif %}

Then clear your theme and ocmod caches.

DigitCart
  • 2,980
  • 2
  • 18
  • 28
  • 1
    up-voted, because that looks rather plausible to me. – Martin Zeitler Sep 08 '18 at 06:33
  • 1
    Nice, solutions for Opencart 3 seem to be rare at this time and the older ones don't work anymore. This should be helpful for other tpp. I hope OP nozices this as he was frustrated and I was not very helpful on this. – ComputerVersteher Sep 08 '18 at 06:37
0

`

<link href="catalog/view/theme/your-theme/stylesheet/stylesheet.css" rel="stylesheet">    
{% if direction == 'rtl' %}
    <link href="catalog/view/theme/your-theme/stylesheet/stylesheet-rtl.css" rel="stylesheet"> 
{% endif %}

`

in stylesheet-rtl.css just add what will change in RTL version so you get smaller file size

Mehde mohamad
  • 71
  • 1
  • 2