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:
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!
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!
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(); ?>
works great! but if there is no $lang, i got an error like
.
it's possible to handle that?
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?
I believe there was a typo in the code above. Here is a working version:
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:
<?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";
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...
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...
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 ?