[Resolved] Language switcher not in responsive WP menu?

Home Support English Support [Resolved] Language switcher not in responsive WP menu?

Tagged: ,

This topic contains 14 replies, has 3 voices, and was last updated by  Eero 6 months, 3 weeks ago. The support staff assigned to this topic is Harshad.

Viewing 15 posts - 1 through 15 (of 15 total)
Author Posts
Author Posts
September 15, 2013 at 11:21 pm #264251

Eero

Hello,

I am working on this for my client, and just found that when viewing the menu at mobile size (when the menu changes to a list view, not sure what that is called) the language switcher is not in the main menu. For the moment I have activated the widget and footer as well, so the site is at least usable for his clients, but I really want the switcher to be in the main menu.

I have read a lot of threads on this and the solutions seem to be unique every time.

Is there a way to fix this on my site?

http://www.businessmapmaker.com theme is called Rudder

- The menu is a WP menu and is administered under Appearance > Menus
- WP 3.6.1
- WPML Multilingual CMS Installed 2.9.2

Any help is most welcome.

September 16, 2013 at 6:30 am #264291

andreas.n
Forum moderator

Hello Eero,

To make sure that we see exactly what you see – which emulator/development environment are you using for mobile development?
Thanks!

September 16, 2013 at 6:44 am #264300

Eero

Hi, (it appears I was logged into Eero's account when making the post, I am his graphic designer)

As I'm not a programmer I'm not 100% sure what you are asking. But I can say that when viewing the site I am using an iPhone (continually deleting the cache) and my desktop browser.

Thanks, Petter.

September 16, 2013 at 12:54 pm #264566

andreas.n
Forum moderator

Hello Petter,

I've checked the site with my desktop browser + Samsung S2, you are right.

Could you provide me with a screenshot of your settings under "WPML > Languages > Language Swither Options" ?
Thanks!

September 16, 2013 at 1:26 pm #264598

Eero

Sure thing. There are two screen shots.

September 17, 2013 at 7:52 am #264938

Harshad
Forum moderator

Hello Petter,

Can you choose the other option in Language Switcher style "Drop down style", from Mobile friendly always to different options and see if it helps.

September 17, 2013 at 8:05 am #264953

Eero

Hi, yes, I had already tried all options (and even now again) but there are no changes with any of them. I had tried Classic, Mobile friendly for mobile agents only, and Mobile friendly always.

Any other tips?

September 17, 2013 at 9:27 am #265007

Harshad
Forum moderator

Hello Petter,

Can you please check with your theme author, if he is using different function/call to display menu on mobiles other than default wordpress call?

September 23, 2013 at 6:31 am #267398

Eero

Hello Harshad,

The theme author finally got back to me and wrote:

"There are two main menus but they both use the same ‘primary’ menu ID, the mobile display is generated manually to create a select/dropdown from the function cudazi_alternate_menu in functions.php."

Is there a workaround for us?

September 23, 2013 at 8:11 am #267470

Harshad
Forum moderator

Can you please paste the php code here of function cudazi_alternate_menu here, so that we can check it.

September 23, 2013 at 8:33 am #267487

Eero
	
	// Alternate menu for small screens
	if ( ! function_exists( 'cudazi_alternate_menu' ) ) {
		function cudazi_alternate_menu( $args = array() ) {			
			
			if ( has_nav_menu( 'primary' ) ) {
			
				$output = '';
				
				// Defaults
				$menu_name = 'primary';
				$display = 'select';
				
				// Grab and apply args from function
				extract($args);						
				
				if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $menu_name ] ) ) {
				
					$menu = wp_get_nav_menu_object( $locations[ $menu_name ] );						
					$menu_items = wp_get_nav_menu_items( $menu->term_id );				
					$output = "<select id='navigation-small'>";
					$output .= "<option value='' selected='selected'>" . __('Go to...', 'cudazi') . "</option>";
					foreach ( (array) $menu_items as $key => $menu_item ) {
					    $title = $menu_item->title;
					    $url = $menu_item->url;
						    
					    if ( $menu_item->menu_item_parent ) {
							$title = ' - ' . $title;
					    }
					    $output .= "<option value='" . $url . "'>" . $title . '</option>';
					}
					$output .= '</select>';
			    }
		
				return $output;							
			} // has menu
		}
	}
September 23, 2013 at 10:09 am #267557

Harshad
Forum moderator

Please use the revised code below:

	
	
	// Alternate menu for small screens
if ( ! function_exists( 'cudazi_alternate_menu' ) ) {
    function cudazi_alternate_menu( $args = array() ) {        
         
        if ( has_nav_menu( 'primary' ) ) {
         
            $output = '';
             
            // Defaults
            $menu_name = 'primary';
            $display = 'select';
             
            // Grab and apply args from function
            extract($args);                    
             
            if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $menu_name ] ) ) {
             
                $menu = wp_get_nav_menu_object( $locations[ $menu_name ] );                    
                $menu_items = wp_get_nav_menu_items( $menu->term_id );              
                $output = "<select id='navigation-small'>";
                $output .= "<option value='' selected='selected'>" . __('Go to...', 'cudazi') . "</option>";
                foreach ( (array) $menu_items as $key => $menu_item ) {
                    $title = $menu_item->title;
                    $url = $menu_item->url;
                         
                    if ( $menu_item->menu_item_parent ) {
                        $title = ' - ' . $title;
                    }
                    $output .= "<option value='" . $url . "'>" . $title . '</option>';
                }
				$languages = icl_get_languages('skip_missing=0&orderby=code');
    			if(!empty($languages)){
        		foreach($languages as $l){
            	$output .= "<option value='" . $l['url'] . "'>"
            	$output .= '<img src="'.$l['country_flag_url'].'" height="12" alt="'.$l['language_code'].'" width="18" /> '.$l['native_name'];
            	$output .= '</option>';
        }
    }

                $output .= '</select>';
            }
     
            return $output;                        
        } // has menu
    }
}
September 23, 2013 at 10:21 am #267579

Eero

Hi Harshad,

Upon updating the code all I get on the page is:

Parse error: syntax error, unexpected '$output' (T_VARIABLE) in /storage/content/54/164654/businessmapmaker.com/public_html/wp-content/themes/rudder/functions.php on line 311

See:
http://www.businessmapmaker.com/

Cheers.

September 23, 2013 at 10:32 am #267591

Harshad
Forum moderator

Sorry ; semicolon was missing, please use the revised code below:

// Alternate menu for small screens
if ( ! function_exists( 'cudazi_alternate_menu' ) ) {
    function cudazi_alternate_menu( $args = array() ) {       
          
        if ( has_nav_menu( 'primary' ) ) {
          
            $output = '';
              
            // Defaults
            $menu_name = 'primary';
            $display = 'select';
              
            // Grab and apply args from function
            extract($args);                   
              
            if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $menu_name ] ) ) {
              
                $menu = wp_get_nav_menu_object( $locations[ $menu_name ] );                   
                $menu_items = wp_get_nav_menu_items( $menu->term_id );             
                $output = "<select id='navigation-small'>";
                $output .= "<option value='' selected='selected'>" . __('Go to...', 'cudazi') . "</option>";
                foreach ( (array) $menu_items as $key => $menu_item ) {
                    $title = $menu_item->title;
                    $url = $menu_item->url;
                          
                    if ( $menu_item->menu_item_parent ) {
                        $title = ' - ' . $title;
                    }
                    $output .= "<option value='" . $url . "'>" . $title . '</option>';
                }
                $languages = icl_get_languages('skip_missing=0&orderby=code');
                if(!empty($languages)){
                foreach($languages as $l){
                $output .= "<option value='" . $l['url'] . "'>";
                $output .= '<img src="'.$l['country_flag_url'].'" height="12" alt="'.$l['language_code'].'" width="18" /> '.$l['native_name'];
                $output .= '</option>';
        }
    }
 
                $output .= '</select>';
            }
      
            return $output;                       
        } // has menu
    }
}
September 23, 2013 at 10:50 am #267607

Eero

Those pesky little things do sometimes have a life of their own. ;)

I can't thank you enough for your excellent support throughout this issue. I see how many requests you get daily, so it's admirable you can keep up.

All the best, and thanks again.

Viewing 15 posts - 1 through 15 (of 15 total)

You must be logged in to reply to this topic.