我找到了这段代码:
<?php global $language; ?>
<?php global $theme_path; ?>
<ul class="language-switcher-locale-url">
<?php $languages = language_list() ?>
<?php foreach($languages as $lang): ?>
<?php $active = $language->language == $lang->language ? " active" : ""; ?>
<li class="<?php echo $lang->language ?><?php echo $active ?>">
<a href="/<?php echo $lang->prefix ?>">
<img src="/<?php echo $theme_path ?>/images/flags/<?php echo $lang->language ?>.png" alt="<?php echo $lang->language ?>"/>
</a>
</li>
<?php endforeach ?>
</ul>
这会将我从mywebsite.com/de/current_page
重定向到选定的语言ex。 mywebsite.com/en
我可以为我的代码做些什么来将我重定向到mywebsite.com/en/current_page
答案 0 :(得分:2)
你应该尝试使用Drupal提供的url()和request_path()函数,也许这样的东西可以工作:
<?php global $language; global $theme_path; $languages = language_list() ?>
<ul class="language-switcher-locale-url">
<?php foreach($languages as $lang): ?>
<?php $active = $language->language == $lang->language ? " active" : ""; ?>
<li class="<?php echo $lang->language ?><?php echo $active ?>">
<a href="<?php echo url(request_path(), array('language' => $lang)); ?>">
<img src="/<?php echo $theme_path ?>/images/flags/<?php echo $lang->language ?>.png" alt="<?php echo $lang->language ?>"/>
</a>
</li>
<?php endforeach ?>
</ul>