open cart 2.2 Change style.css based on language or direction

I am trying change style.css based on language or direction in open cart 2.2

I have this input:

<link type="text/css" href="view/stylesheet/stylesheet.css" rel="stylesheet" media="screen" />

i want change stylesheet.css to stylesheet-rtl.css

This is my try:

<?php $session = new Session();?>
<?php $lang = $session->data['language']; ?>
        <?php    if ($lang == 'ar') { ?>
      <link type="text/css" href="view/stylesheet/stylesheet-rtl.css" rel="stylesheet" media="screen" />
            <?php } else {  ?>
         <link type="text/css" href="view/stylesheet/stylesheet.css" rel="stylesheet" media="screen" />
            <?php } ?>

This worked for opencart 2.0.X but not in opencart 2.2.

What changed?

Answers


if you are using OC 2.2 you can try this code

      <?php $direction = $this->language->get('direction'); ?>
       <?php   if ($direction == 'rtl')  { ?>

      <link type="text/css" href="view/stylesheet/stylesheet-rtl.css" rel="stylesheet" media="screen" />

            <?php } else {  ?>

         <link type="text/css" href="view/stylesheet/stylesheet.css" rel="stylesheet" media="screen" />

            <?php } ?>

Need Your Help

Whats wrong with this regular expression?

php regex pcre

I have the following regular expression to find word in text and highlight them