<?php
$pageurl = "http://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
$pageurl_noslashes = str_replace("/","",$pageurl);
$lang = substr($pageurl_noslashes,-3);
echo $lang;
?>
{exp:channel:entries channel="products" limit="10"}
<p>Product title: <span>{if title<?php echo $lang; ?>} {title<?php echo $lang; ?>} {if:else} {title} {/if}</span></p>
{/exp:channel:entries}
我正在破解表达式引擎以返回适当的语言变量。
我知道我获取语言代码(fr/en/etc...)的方式远非理想,这就是为什么我需要关于它的建议:)
怎么了:
- host.com/products/item/_fr/ — 加载法语
- host.com/products/item/_en/ — 加载英文
- host.com/products/item/ — 加载英语(在 if 条件失败后)
所以从本质上讲,它正是我想要的,但我觉得这不是最好的方法。