Integration with WP3 Nav Menu Feature

Having Problems? Need Help? Post here!

Re: Integration with WP3 Nav Menu Feature

Postby brunopinho » Thu Mar 03, 2011 4:54 pm

Any way of removing the <!--:en -->Test EN<!--:--><!--:fr -->Test Fr<!--:--> on the "Menus" management back office page without "hammering" any WP core files?
I'd really like to get this fixed, but I don't want to change any core files.

Thanks!


--
Bruno
brunopinho
 
Posts: 8
Joined: Wed Feb 23, 2011 9:08 am

Re: Integration with WP3 Nav Menu Feature

Postby abmcr » Sat Apr 02, 2011 4:47 pm

The only method for not hack the core is extends the function
I have try to override the function start_el() in the class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu into the nav_menu.php file (line 220...)
In my function i have try width

Code: Select all
class A extends Walker_Nav_Menu_Checklist{
     function start_el(){
.......

but i get an error

Fatal error: Class 'Walker_Nav_Menu_Checklist' not found in.....
Any suggestion?
abmcr
 
Posts: 13
Joined: Sat Feb 06, 2010 4:04 pm

Re: Integration with WP3 Nav Menu Feature

Postby haba » Mon May 09, 2011 7:07 pm

Hi,
First of all thanks for this great plugin Qian!

I made my "dirty hack" to remove the ugly <!--:en-->...<!--:-->... texts on the nav menu admin page:
It's mostly a javascript based solution and it's not perfect, but it does these things:
- adds a language meta box, so user can choose a qTranslate language
- replaces the most important dirty (<!--:en-->...<!--:-->) texts, labels, and input values with the actual language part
- updates the "hidden" dirty language part when the user change the navigation label's value
- restore the updated ugly values of navigation labels when user save the menu or refresh the page

Attachments:
functions.txt
(1008 Bytes) Downloaded 488 times
rename it to functions.php or insert its content into your functions.php - it adds the language metabox and the js file
qt-nav-menu.txt
(3.05 KiB) Downloaded 424 times
rename it to qt-nav-menu.js and copy to your theme folder - it makes all the magic :-)

Cheers!
haba
 
Posts: 1
Joined: Mon May 09, 2011 6:35 pm

Re: Integration with WP3 Nav Menu Feature

Postby abmcr » Tue May 10, 2011 6:56 am

Thank you: all work fine.... bravo!!!!
a simple solution for a big problem
abmcr
 
Posts: 13
Joined: Sat Feb 06, 2010 4:04 pm

Re: Integration with WP3 Nav Menu Feature

Postby abmcr » Sun May 22, 2011 9:33 am

I have used the two file and all work fine, but i have not the ability to set a different label for each language...
may be i have not well understanding :-(
Thank you
abmcr
 
Posts: 13
Joined: Sat Feb 06, 2010 4:04 pm

Re: Integration with WP3 Nav Menu Feature

Postby jewelryab » Tue May 24, 2011 6:16 am

I'm sure they can work with the Twenty Ten theme. Did you use WP3's native nav menu? What actually is not working for you?
jewelryab
 
Posts: 3
Joined: Tue May 24, 2011 6:00 am

Re: Integration with WP3 Nav Menu Feature

Postby fasheezee » Tue Jun 14, 2011 11:29 am

how does it works with wp_list_pages?
fasheezee
 
Posts: 7
Joined: Fri May 27, 2011 7:25 pm

Re: Integration with WP3 Nav Menu Feature

Postby clady » Tue Jun 14, 2011 2:55 pm

How i can exclude one menu item if it is not present in selected language?
I would not visualize submenu items not present in selected language.

Thanks.
clady
 
Posts: 1
Joined: Tue Jun 14, 2011 2:50 pm

Re: Integration with WP3 Nav Menu Feature

Postby kevmille » Sat Nov 05, 2011 3:24 pm

bedex78 wrote:Here's another method to direct the links correctly... This time using FILTER, so you can skip the 'Walker' argument in the wp_nav_menu function call.

Code: Select all
add_filter('walker_nav_menu_start_el', 'qtrans_in_nav_el', 10, 4);
function qtrans_in_nav_el($item_output, $item, $depth, $args){
    $attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';
    $attributes .= ! empty( $item->target )     ? ' target="' . esc_attr( $item->target     ) .'"' : '';
    $attributes .= ! empty( $item->xfn )        ? ' rel="'    . esc_attr( $item->xfn        ) .'"' : '';
   
   // Determine integration with qTranslate Plugin
   if (function_exists('qtrans_convertURL')) {
      $attributes .= ! empty( $item->url ) ? ' href="' . qtrans_convertURL(esc_attr( $item->url )) .'"' : '';
   } else {
      $attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
   }
   
   $item_output = $args->before;
   $item_output .= '<a'. $attributes .'>';
   $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
   $item_output .= '</a>';
   $item_output .= $args->after;
      
   return $item_output;
}


Thank you very much for this. I spent the whole day trying to figure this out with one of the Wordpress sites I am working on for a security company. I am using WooTheme's Canvas theme. I just added this to functions.php and it worked!!! Got the Home link working for English, Japanese and Vietnamese.

This will make many canvas users happy. Now I just got to figure out how to get the breadcrumbs to localise correctly. :D
Blogs: SaigonNezumi.com / TheRightBrainer
Company: Hakata Group
Location: Ho Chi Minh City (Saigon), Vietnam

I love Vietnam!
kevmille
 
Posts: 2
Joined: Sat Nov 05, 2011 3:17 pm
Location: Saigon, Vietnam

Re: First of all - thanks to bedex78 Re: Integration with WP3

Postby mahasvin » Mon Dec 05, 2011 5:57 pm

WOO Themes redirect hack also worked for me before I discovered this thread.
Create page with template Redirect, point menu item to it.
Code: Select all
<?php
/*
Template Name: Redirect
*/
?>

<?php
/*

USAGE INSTRUCTIONS:

1. Create a new page in WordPress
2. Add a title to the page (e.g. WooThemes)
3. Add an URL to the content of the page (e.g. http://www.woothemes.com OR woothemes.com OR www.woothemes.com)
4. Select "Redirect" as the page template
5. Publish!

*/
?>

<?php if (have_posts()) : the_post() ?>
<?php $URL_en = get_the_excerpt();
if (!preg_match('/^http:\/\//', $URL_en)) $URL_en = 'http://yoursite.com/'.qtrans_getLanguage('',$language). $URL_en; ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Refresh" content="0; url=<?php echo $URL_en; ?>">
</head>

<body>
</body>
</html>


<?php endif; ?>
mahasvin
 
Posts: 19
Joined: Mon May 10, 2010 12:42 pm

PreviousNext

Return to qTranslate Support Forum

Who is online

Users browsing this forum: Google [Bot] and 4 guests

cron