Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SOLVED i18n Нow to remove the menu item from the output
#1
Information 
Hi!
I need your help.
I want to display two menu on the site  -  main menu + off-canvas menu(for mobile).

In the main menu, one of the items i need hide.
In the off-canvas menu(for mobile) we need all menu items including hidden in main menu.

To display the main menu, I use:

PHP Code:
<?php get_i18n_navigation(return_page_slug(),0,1,I18N_SHOW_MENU'menu'); ?>

To display the off-canvas menu, I use:

PHP Code:
<?php get_i18n_navigation(return_page_slug(),0,99,I18N_SHOW_MENU'off-canvas'); ?>

I tried to disable the desired option in the admin panel - "turn on / off the visibility of the in menu". BUT THEN the item is lost in both menu.

Maybe there is some php code like menu rendering to remove an item from the menu, knowing link page or ID or name page or slug or something else.
PHP I do not know, I can only slightly edit.
I use machine translation. Forgive me my errors.
Reply
#2
Problem solved! CUSTOM RENDERING and PHP
I use machine translation. Forgive me my errors.
Reply
#3
I leave here a way to solve. Maybe it will help someone.
I use machine translation. Forgive my errors.
There are two ways:
First method - it is simple, but it is better not to use it)

It only hides the menu item from the user. In the page code ("Ctrl + U" in browser) all hidden will be seen and it is wrong!
Add using CSS for the tag <li>:
   display: none !important;
   visibility: hidden !important;
GetSimple It adds a number of additional classes for tags - use them.
The following apply: I18N Plugin, HTML, CSS
Example:
In example we hides menu item "vidy-rabot"...
Class .menu-top-primary - name depends on your imagination
Class .vidy-rabot - name depends on "page slug"
HTML code in template:
PHP Code:
<nav class="menu-top-primary"
 <
ul
 
 <?php get_i18n_navigation(return_page_slug(),1,1); ?>
 </ul> 
</nav> 

CSS code:
If there is a menu item which constant reference "vidy-rabot" and it should hide in the menu - то then write a CSS:

Code:
.menu-top-primary li.vidy-rabot {
 display: none !important;
 visibility: hidden !important;
}

So we can hide any menu item based on its "page slug". Instead "vidy-rabot", use your.
I use machine translation. Forgive me my errors.
Reply
#4
The second method:
The second method is interesting. That's what I was looking for.
The following apply: I18N Plugin, HTML, CSS and some PHP.
Menu rendering in components and code in Html targeted for UIkit 2.27.2 CSS Framework(https://getuikit.com/v2/)

Here I want to show only methodWink
Component:
<?php get_component('off-canvas-menu'); ?>
PHP Code:
<?php
$s 
= array('current''activepath''currentpath''open');
$r = array('uk-active''active''active''uk-parent');
$c str_replace($s$r$item->classes);
?>
<?php
if ($item->url == 'vidy-rabot'){
 
 $bc return_i18n_breadcrumbs(return_page_slug());
 
 get_i18n_navigation($bc[0]['url']=='vidy-rabot'?return_page_slug():'vidy-rabot',1,2,I18N_SHOW_MENU'off-canvas-menu');
} else {
?>
<li class="<?php echo $c?>">
  <?php if ($item->isOpen) { ?>
    <a href="#">
      <?php echo htmlspecialchars($item->text); ?>
    </a>
    <ul class="uk-nav-sub">
       <?php $item->outputChildren(); ?>
    </ul>    
  <?php } else { ?>
    <a href="<?php echo htmlspecialchars($item->link); ?>">
      <?php echo htmlspecialchars($item->text); ?>
    </a>    
  <?php ?>
</li>
<?php ?>

This is what you need) Checking for compliance URL:
if ($item->url == 'vidy-rabot')

This code displays all of the child items for page 'vidy-rabot':
$bc = return_i18n_breadcrumbs(return_page_slug());
get_i18n_navigation($bc[0]['url']=='vidy-rabot'?return_page_slug():'vidy-rabot',1,2,I18N_SHOW_MENU, 'off-canvas-menu');


In this way, we can replace one menu item to another, or to include all its subsidiary pages instead of the menu, as shown here.

This code inserts the template:
Code:
<div id="offcanvas" class="uk-offcanvas">
 <div class="uk-offcanvas-bar uk-offcanvas-bar-flip">            
   <ul class="uk-nav uk-nav-offcanvas uk-nav-parent-icon uk-margin-bottom uk-margin-top" data-uk-nav="{multiple:true}">
     <?php function_exists('get_i18n_navigation') ? get_i18n_navigation(return_page_slug(),0,99,I18N_SHOW_MENU,'off-canvas-menu') : get_navigation(get_page_slug(FALSE)); ?>
   </ul>
 </div>
</div>
I use machine translation. Forgive me my errors.
Reply




Users browsing this thread: 1 Guest(s)