Php Opencart:如何根据语言加载不同的CSS样式

Php Opencart:如何根据语言加载不同的CSS样式,php,html,opencart,opencart-3,Php,Html,Opencart,Opencart 3,我使用opencart 当语言为ar时,我想加载样式表-rtl.css 和stylesheet.css(当语言为en时) 我试过这个和其他一些我在网上找到的,但它不起作用 <?php if($direction == "rtl"){?> <link href="catalog/view/theme/tt_palora1/stylesheet/style.css" rel="stylesheet"> <?php } else { ?> <l

我使用opencart 当语言为ar时,我想加载样式表-rtl.css 和stylesheet.css(当语言为en时)

我试过这个和其他一些我在网上找到的,但它不起作用

<?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 }?>


有什么帮助吗?

header.php中有一个
方向
变量:

$data['direction'] = $this->language->get('direction');
您可以在视图文件中使用它,编辑此文件

catalog\view\theme\your-theme\template\common\header.twig
查找:

<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">
{% else %}
    <link href="catalog/view/theme/your-theme/stylesheet/stylesheet.css" rel="stylesheet">
{% endif %}

将其替换为:

<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">
{% else %}
    <link href="catalog/view/theme/your-theme/stylesheet/stylesheet.css" rel="stylesheet">
{% endif %}
{%if-direction='rtl%}
{%else%}
{%endif%}
然后清除主题和ocmod缓存。

`

<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 %}

{%if-direction=='rtl%}
{%endif%}
`


在stylesheet-rtl.css中,只需添加在rtl版本中会发生什么变化,这样您就可以获得更小的文件大小

您天生就具备php技能?我是前端开发人员,但今天我有了上面的问题!有什么问题吗。如果你能回答我,请把这张桌子读一下。我们不是编码服务。一个提示:要在php中输出一些东西,请使用
echo
。阅读上面的我说“有什么帮助吗?”但你来到这里,就像你天生就有php技能一样。我尝试了许多在互联网上找到的答案,但都不管用,阅读上面的我说我尝试了很多,你认为我是来浪费时间的吗?投票结果是一致的,因为这在我看来似乎是合理的。不错,Opencart 3的解决方案在这个时候似乎很少见,而旧的解决方案已经不起作用了。这应该对其他tpp有所帮助。我希望OP nozices能做到这一点,因为他很沮丧,而我在这方面并没有提供太多帮助。