Switch Language Block in Autonav results in 404

Good evening

I'm working on a design that calls for the Switch Language functionality to be included in the Autonav. I managed to do that by including a stack in my custom responsive_header_navigation Template. When I now try to switch the language from English to German, I get a 404 "Page Not Found" error.

Funnily enough, when I also add an instance of the Switch Language block to the page for which I'm trying to switch languages, it works i.e. both the block on the page and the block included in the autonav work.

Has anyone else run into this? Does anyone see any obvious problems with my setup, detailed below?

<div class="ccm-responsive-menu-footer">
 $stack = Stack::getByName('Navigation Social Links and Language Switch');

(The stack also includes the Social Links Block.)

<?php defined('C5_EXECUTE') or die("Access Denied.");?>
<div class="ccm-block-switch-language-text">
    <?php foreach($languageSections as $ml) { 
       $lang = $ml->getLanguageText($locale);
        <a href="<?php echo $view->action('switch_language', $cID, $ml->getCollectionID())?>"
           title="<?php echo $lang;?>"><?php echo $lang;?></a>
           <p><?php echo $cID . ' / ' . $ml->getCollectionName(); ?></p>
    <?php } ?>

Case 1: On page "Our Service", with Switch Language Block added to page:

URL for English (on page)

URL for German (on page)

URL for English (in autonav)

URL for German (in autonav)

In this scenario, both blocks work, i.e. the language is switched.

Example: On page "Our Service" with Switch Language Block only present in Autonav:

URL for English

URL for German

In this case, even though it's the same URL as above, I get a 404.

Any feedback and hints would be much appreciated :)

View Replies:
c5dragon replied on at Permalink Reply
'Hardcoding' this block won't load the JS necessary to switch lang.
By adding it the normal way the JS is included. So both work.
publicb replied on at Permalink Reply
Thanks for taking the time to read my post and answer!

For testing purposes, I tried loading the switch_language block's view.js in the footer, like so:

<script type="text/javascript" src="/c5site/concrete/blocks/switch_language/view.js"></script>

The code in that file seems to only apply to the default view template for the block, which uses a select element:

$(function() {
   $('select[data-select=multilingual-switch-language]').change(function() {
        var action = $(this).attr('data-action').replace('--language--', $(this).val());
        window.location.href = action;

I also tried to switch the block's view template to the default one in the stack loaded in my Autonav. The problem persists.

Plus, when I remove the non-hardcoded block from the page again, the problem reappears. Are there other assets associated with this block I should be aware of?
c5dragon replied on at Permalink Reply
Best to create a global area with nav and switch and use css to 'combine' them.

In the controller of the switch language block is an asset requirement for the view.
public function view()
   $this->requireAsset('javascript', 'jquery');

Depends on the rest of your template/code/blocks if JQ is actually loaded.

But it is probably not going to work: