Help with autonav

Permalink
Hi Guys

I'm using C5.5.2.1 with the free internationalization add-on. I've created a structure like this:

Home
 - English
 -- Home
 -- Page 1
 - Spanish
 --- Home
 -- Page 2


I have added the languages and I can switch between them properly using the Language Switcher.

The problem I have is with the autonav. I don't know how to display a different autonav per language. I have created two autonav blocks and in my template I have a GlobalArea.

Any ideas?

Thanks!

 
tlloyduk replied on at Permalink Reply
I should add that when I am creating an AutoNav I'm getting it to start from beneath "English" and another one beneath "Spanish". This gives me the pages underneath each section.

So I am wondering now how to display the appropriate AutoNav block in the global area depending on what language is active ?

Or is there a better way ?
tlloyduk replied on at Permalink Reply
I always ask a question then shortly after figure it out - doh.

<?php
          Loader::model('section', 'multilingual');
          $lang = MultilingualSection::getCurrentSection()->getLanguage();
          if($lang == "en") {
                  $a = new GlobalArea('Header Nav English');
          } elseif($lang == "es") {
                  $a = new GlobalArea('Header Nav Spanish');
          } else {
                  $a = new GlobalArea('Header Nav English');
          }
          $a->display();
          ?>
webpresso replied on at Permalink Reply
webpresso
works great! but if there is no $lang, i got an error like
Fatal error: Call to a member function getLanguage() on a non-object in /home/eglifede/public_html/themes/custom_theme/default.php on line 16
.

it's possible to handle that?
Apos replied on at Permalink Reply
Apos
I believe there was a typo in the code above. Here is a working version:

<?php
    $lh = Loader::helper('section', 'multilingual');
    $lang = $lh->getLanguage();
    if($lang == "en") {
        $a = new GlobalArea('Header Nav English');
    } else if($lang == "es") {
        $a = new GlobalArea('Header Nav Spanish');
    } else {
        $a = new GlobalArea('Header Nav English');
    }
    $a->display();
?>


Note: You may need to verify whether "en" and "es" is the correct language code. You can do so by adding the following line right before the closing PHP tag:

echo "Current language code: " . $lang . "\n";
nickratering replied on at Permalink Reply
nickratering
Hello,

This work great on the front-end, but how can I work around this in the dashboard?
I'm having the fatal error in the dashboard > page types > defaults.

Best,
Nick

EDIT - Found a solution: :D
http://www.concrete5.org/community/forums/customizing_c5/programmat...