dongqingchan2385 2016-12-14 15:47
浏览 37

Concrete5:如何为多语言网站创建自定义导航?

I need to create multilingual site with Concrete5 (v 5.7).

I've a custom theme and my page layout would be:

Home
|-en
|--Frontpage
|--Contatcs
|-<language2>
|--<Frontpage>
|--<Contacts>

With current navigation implementation:

<nav class="nav">
<?php
$bt_main = BlockType::getByHandle('autonav');
$bt_main->controller->displayPages = 'top';
$bt_main->controller->orderBy = 'display_asc';                    
$bt_main->controller->displaySubPages = 'none';                    
$bt_main->render('templates/level1');
?>
</nav>

I get the result where in the navigation there is only | EN | <language2>|

Can't find any proper document how to fix or use multilingual settings.

  • 写回答

1条回答 默认 最新

  • doubeishuai6598 2016-12-21 14:24
    关注

    With Concrete5 version 5.7.x.x you can use Global areas. Global areas can be setup differently for each language.

    When using a global area, you can add an autonav block on one language and show pages below and in the other language you can add an autonav block which shows pages below .
    Another advantage of working with a global area is the templates. Hardcoded blocks are known to always show the default template (view.php, view.css).

    If you do not want anyone else (except the superuser) to be able to edit the global area, you can use this code:

    $u = new User();
    $areaNav = new GlobalArea('Navigation');
    if(!$u->isSuperUser()){
      $areaNav->disableControls();
    }
    $areaNav->display($c);
    

    If you really want to work with a hardcoded block, you can still check for the language and load a different (hardcoded) block for each language.

    $lang = Localization::activeLanguage();
    if($lang == 'en'){
      //hardcoded block for english language
    }else if($lang == 'fr'){
      //hardcoded block for french language
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法