GetSimple Support Forum
Problem with I18N navigation menu - Printable Version

+- GetSimple Support Forum (http://get-simple.info/forums)
+-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3)
+--- Forum: Plugins (http://get-simple.info/forums/forumdisplay.php?fid=13)
+--- Thread: Problem with I18N navigation menu (/showthread.php?tid=9497)



Problem with I18N navigation menu - BF68 - 2017-02-05

Hi There,

Just started with GetSimple which I wnat to use to rebase my private website. My current private website at www.lieberlinge.de is completely handmade and somewhat outdated.
The goals of rebasing it on a CMS like GetSimple are:
  • Make it easier to change the look and feel
  • Allow my wife without html knowledge to update the site
  • Get a more modern look and feel
One of my key requirements for the new site is a multilevel navigation bar and when I checked the options with GetSimple a couple of months ago I didn't discover I18N. Now with I18N it should be possible in a simple way to get such a left-side navigation menu.

However I struggle to get it to work. I have built the following pages:

[Image: 32595114591_d3d8eaa8c2_b.jpg]20170205_Screenshot1 by Bernie None, auf Flickr

I use the theme "ThemeSettingsDemo" and in it's default template.php I have the following mostly unchanged section:

PHP Code:
   <div id="main">
 
       <div id="navigation">
 
           <ul><?php get_i18n_navigation(return_page_slug(), 0100I18N_SHOW_MENU); ?></ul>
        </div>
    </div> 



But if I call the site it shows the following
[Image: 32338461360_29b71a99d8_b.jpg]20170205_Screenshot2 by Bernie None, auf Flickr

Where I miss in the red circle the expected navigation menu.

Anyone any idea how to fix the issue?

Many thanks in advance!

Bernhard


RE: Problem with I18N navigation menu - Bigin - 2017-02-05

Select "Add this page to the menu" checkbox under the Page options

http://get-simple.info/forums/showthread.php?tid=1256&pid=57804#pid57804


RE: Problem with I18N navigation menu - BF68 - 2017-02-05

Was of course already checked, see

[Image: 32679554056_695cec84c7_b.jpg]

Any other thoughts?

I rund the webserver on my private Synology NAS system. What I did just lately is that I updated access rights for the group "http" on the Synology from "read-only" to "full-Access". Still without any improvement...


RE: Problem with I18N navigation menu - BF68 - 2017-02-05

Hi All,

Seems I've solved the first issue. Insufficient access rights for the webserver on my NAS apparently have been the root cause. After configuring proper access rights on the NAS and after editing the menu structure in GetSimple I18N again it works (almost) as desired:

[Image: 32597329591_d62f5be1c4_b.jpg]20170205_Screenshot4 by Bernie None, auf Flickr

Now I have the following question:

How can I get a behaviour of the left-side navigation menu where first only the top-level entries are shown an if for instannce  "Hobbies" is clicked then the menu opens and shows the sub-entries "Mountainbike" in this case? Is this possible?

And apologies, if this is a stupid question but I'm total newbie to php and to GetSimple. On the other hand I can code some perl so it should not be too difficult for me to understand the basics.

I'm looking forward to any hint.

Best regards

Bernhard


RE: Problem with I18N navigation menu - BF68 - 2017-02-05

Ah figured it already out, I18N_SHOW_NORMAL does the job, now on to the next challenge:

How can I have a menu as in the above sample where a click to "Hobbies" does NOT open a page but only opens the submenu? Is this possible?


RE: Problem with I18N navigation menu - Tyblitz - 2017-02-06

(2017-02-05, 20:12:26)BF68 Wrote: Ah figured it already out, I18N_SHOW_NORMAL does the job, now on to the next challenge:

How can I have a menu as in the above sample  where a click to "Hobbies" does NOT open a page but only opens the submenu? Is this possible?

Hi there, BF68,

There is no such feature included out of the box that I know of.
A while ago I wrote a function for I18N navigation where:
  • if the page has child pages, it only opens the sub-menu.
  • if the page doesn't have child pages, it opens the page.
You can see it at this website: http://seiltanzen.com

The code is the following (include it in your theme): 

PHP Code:
function i18nMenuNoLandingPages($links$loop 0) { 
 
   global $SITEURL$language;
 
   $y count($links);
 
   static $str '';
 
   $str $str '<ul>';
 
   for ($x 0$x $y $x++) {
 
     $item $links[$x];
 
     $str $str '<li>';
 
     if ($item['haschildren']) {
 
       $str $str $item['title'];
 
       $str i18nMenuNoLandingPages($item['children'], $loop++, $str);
 
     } else if ($item['haschildren'] === false) {
 
         // depending on your URL structure, you will need to change this line
 
         $str $str '<a href="' $SITEURL . (strlen($item['parent']) ? $item['parent'] .'/' ''). $item['url'] . '">' $item['title'] . '</a>';
 
     }
 
     $str $str '</li>';
 
   }
 
   $str $str '</ul>';
 
   return $str;
 
 

And you use it like this: 

PHP Code:
 $nav return_i18n_menu_data(return_page_slug(),0,5,I18N_SHOW_MENU);
 
 echo i18nMenuNoLandingPages($nav); 


However: depending on your .htaccess rewrite rules and whether you use pretty urls, you will need to change one line in the code. In your admin dashboard, have you checked "Use fancy URLs?" and set a custom permalink structure?
This code was written for a permalink structure like: /%parent%/%slug%/ (eg. http://mysite/hobbies/fishing).


RE: Problem with I18N navigation menu - BF68 - 2017-02-06

(2017-02-06, 04:45:37)Tyblitz Wrote: Hi there, BF68,

There is no such feature included out of the box that I know of.
A while ago I wrote a function for I18N navigation where:
  • if the page has child pages, it only opens the sub-menu.
  • if the page doesn't have child pages, it opens the page.
You can see it at this website: http://seiltanzen.com
...
However: depending on your .htaccess rewrite rules and whether you use pretty urls, you will need to change one line in the code. In your admin dashboard, have you checked "Use fancy URLs?" and set a custom permalink structure?
This code was written for a permalink structure like: /%parent%/%slug%/ (eg. http://mysite/hobbies/fishing).

Hi There,

Many thanks for the reply and the suggestion. This sounds great. I will have time only next weekend to work with it and test it in my environment.

I'll keep you posted

Have a great week!


RE: Problem with I18N navigation menu - BF68 - 2017-02-12

(2017-02-06, 04:45:37)Tyblitz Wrote:
(2017-02-05, 20:12:26)BF68 Wrote: Ah figured it already out, I18N_SHOW_NORMAL does the job, now on to the next challenge:

How can I have a menu as in the above sample  where a click to "Hobbies" does NOT open a page but only opens the submenu? Is this possible?

Hi there, BF68,

There is no such feature included out of the box that I know of.
A while ago I wrote a function for I18N navigation where:
  • if the page has child pages, it only opens the sub-menu.
  • if the page doesn't have child pages, it opens the page.
You can see it at this website: http://seiltanzen.com

The code is the following (include it in your theme): 

PHP Code:
function i18nMenuNoLandingPages($links$loop 0) { 
 
   global $SITEURL$language;
 
   $y count($links);
 
   static $str '';
 
   $str $str '<ul>';
 
   for ($x 0$x $y $x++) {
 
     $item $links[$x];
 
     $str $str '<li>';
 
     if ($item['haschildren']) {
 
       $str $str $item['title'];
 
       $str i18nMenuNoLandingPages($item['children'], $loop++, $str);
 
     } else if ($item['haschildren'] === false) {
 
         // depending on your URL structure, you will need to change this line
 
         $str $str '<a href="' $SITEURL . (strlen($item['parent']) ? $item['parent'] .'/' ''). $item['url'] . '">' $item['title'] . '</a>';
 
     }
 
     $str $str '</li>';
 
   }
 
   $str $str '</ul>';
 
   return $str;
 
 

And you use it like this: 

PHP Code:
 $nav return_i18n_menu_data(return_page_slug(),0,5,I18N_SHOW_MENU);
 
 echo i18nMenuNoLandingPages($nav); 


However: depending on your .htaccess rewrite rules and whether you use pretty urls, you will need to change one line in the code. In your admin dashboard, have you checked "Use fancy URLs?" and set a custom permalink structure?
This code was written for a permalink structure like: /%parent%/%slug%/ (eg. http://mysite/hobbies/fishing).

Hy Tyblitz,

Unfortunately your function does not really what I expect as it opens all submenues instantly and not only when someone clicks on the menu entry. Do you have any hint about how to modify your code to get the thing done?


RE: Problem with I18N navigation menu - Tyblitz - 2017-02-15

(2017-02-12, 03:59:59)BF68 Wrote: Hy Tyblitz,

Unfortunately your function does not really what I expect as it opens all submenues instantly and not only when someone clicks on the menu entry. Do you have any hint about how to modify your code to get the thing done?

Hi BF68,

This function only generates the navigation structure in the HTML. The click/hover/whatever-you-want behavior is entirely up to you (this is a function, not a plugin). In the example site I provided, it's done with CSS :hover (on mobile, this will open on click), but you can use Javascript/jQuery to make it behave as you wish. You should know some basic CSS/JS, or you can try a jQuery plugin like this one.