Jump to content

Edit History

waterman455

waterman455


translation to france , because i posted in french topic

Salut tous le monde, je veux avoir dans ma menu un data-depth= 1 , dans ce cas la je peux avoir un pop-up affichant les sous catégories de mes catégories au niveau 2 , j'ai une capture ici qui montre que j'ai à ma menu  "PLUS" qui permet d'afficher d'autres catégories , je veux afficher les sous catégories de catégories afficher par plus à un autre popup (level 2) ,  Pour le "PLUS" dans ma menu j'ai inspecter et c'est lier à un code javascript dans my custom.js situé ci dissous

    $(document).ready(function () {

        let moreText = $('#_desktop_top_menu').data('more')

        if (!moreText) {

            'More'

        }

        if ($window.width() >= parseInt($mobile, 10)) {

            var max_elem = 6;

            if ($(window).width() < 1200) {

                max_elem = 5;

            }

            var items = $('#top-menu > li:not(.link)');

            var surplus = items.slice(max_elem, items.length);

            surplus.wrapAll('<li class="more_menu"><div class="popover sub-menu js-sub-menu">');

            $('.more_menu').prepend('<a href="#" id="more_asse" class="dropdown-item" data-depth="0">' + moreText + '</a>');

        } else {

            $("#top-menu > li:not(.link)").removeClass(".more_menu");

        }

    });   >

 

dans ps_mainmenu.tpl  c'est le code par default : 

  {**
 * 2007-2020 PrestaShop
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License 3.0 (AFL-3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * https://opensource.org/licenses/AFL-3.0
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to [email protected] so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
 * versions in the future. If you wish to customize PrestaShop for your
 * needs please refer to http://www.prestashop.com for more information.
 *
 * @author    PrestaShop SA <[email protected]>
 * @copyright 2007-2020 PrestaShop SA
 * @license   https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
 * International Registered Trademark & Property of PrestaShop SA
 *}
{assign var=_counter value=0}
{function name="menu" nodes=[] depth=0 parent=null}
    {if $nodes|count}
      <ul class="top-menu clearfix" {if $depth == 0}id="top-menu"{/if} data-depth="{$depth}">
        {foreach from=$nodes item=node}
            <li class="{$node.type}{if $node.current} current {/if}" id="{$node.page_identifier}">
            {assign var=_counter value=$_counter+1}
              <a
                class="{if $depth >= 0}dropdown-item{/if}{if $depth === 1} dropdown-submenu{/if}"
                href="{$node.url}" data-depth="{$depth}"
                {if $node.open_in_new_window} target="_blank" {/if}
              >
                {if $node.children|count}
                  {* Cannot use page identifier as we can have the same page several times *}
                  {assign var=_expand_id value=10|mt_rand:100000}
                  <span class="float-xs-right hidden-lg-up">
                    <span data-target="#top_sub_menu_{$_expand_id}" data-toggle="collapse" class="navbar-toggler collapse-icons">
                      <i class="material-icons add">add</i>
                      <i class="material-icons remove">remove</i>
                    </span>
                  </span>
                {/if}
                {$node.label}
              </a>
              {if $node.children|count}
              <div {if $depth === 0} class="popover sub-menu js-sub-menu collapse"{else} class="collapse"{/if} id="top_sub_menu_{$_expand_id}">
                {menu nodes=$node.children depth=$node.depth parent=$node}
                {if $node.image_urls|count}
                  <div class="menu-images-container">
                    {foreach from=$node.image_urls item=image_url}
                      <img src="{$image_url}">
                    {/foreach}
                  </div>
                {/if}
              </div>
              {/if}
            </li>
        {/foreach}
      </ul>
    {/if}
{/function}

<div class="menu js-top-menu hidden-md-down" id="_desktop_top_menu" data-more={l s='more' d='Shop.Theme.Catalog'}>
    {menu nodes=$menu.children}
</div>
>

Merci pour votre attention , j'ai besoin d'aide , si vous avez une idée ou bien un conseil comment le faire sa me ferait plaisir merci beaucoup

image.png

waterman455

waterman455

Hello everybody ,  I am to expand my menu at depth = 1 , so that I will get another submenu of the subcategory , my mainmenu looks like in this attached photo, in PLUS ; I want to have another popover showing subcatégory of ampoule;piles...Etc , there is a js content of this PLUS in my custom.js :

    $(document).ready(function () {

        let moreText = $('#_desktop_top_menu').data('more')

        if (!moreText) {

            'More'

        }

        if ($window.width() >= parseInt($mobile, 10)) {

            var max_elem = 6;

            if ($(window).width() < 1200) {

                max_elem = 5;

            }

            var items = $('#top-menu > li:not(.link)');

            var surplus = items.slice(max_elem, items.length);

            surplus.wrapAll('<li class="more_menu"><div class="popover sub-menu js-sub-menu">');

            $('.more_menu').prepend('<a href="#" id="more_asse" class="dropdown-item" data-depth="0">' + moreText + '</a>');

        } else {

            $("#top-menu > li:not(.link)").removeClass(".more_menu");

        }

    });   >

 

in my ps_mainmenu.tpl is the default : 

  {**
 * 2007-2020 PrestaShop
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License 3.0 (AFL-3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * https://opensource.org/licenses/AFL-3.0
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to [email protected] so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
 * versions in the future. If you wish to customize PrestaShop for your
 * needs please refer to http://www.prestashop.com for more information.
 *
 * @author    PrestaShop SA <[email protected]>
 * @copyright 2007-2020 PrestaShop SA
 * @license   https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
 * International Registered Trademark & Property of PrestaShop SA
 *}
{assign var=_counter value=0}
{function name="menu" nodes=[] depth=0 parent=null}
    {if $nodes|count}
      <ul class="top-menu clearfix" {if $depth == 0}id="top-menu"{/if} data-depth="{$depth}">
        {foreach from=$nodes item=node}
            <li class="{$node.type}{if $node.current} current {/if}" id="{$node.page_identifier}">
            {assign var=_counter value=$_counter+1}
              <a
                class="{if $depth >= 0}dropdown-item{/if}{if $depth === 1} dropdown-submenu{/if}"
                href="{$node.url}" data-depth="{$depth}"
                {if $node.open_in_new_window} target="_blank" {/if}
              >
                {if $node.children|count}
                  {* Cannot use page identifier as we can have the same page several times *}
                  {assign var=_expand_id value=10|mt_rand:100000}
                  <span class="float-xs-right hidden-lg-up">
                    <span data-target="#top_sub_menu_{$_expand_id}" data-toggle="collapse" class="navbar-toggler collapse-icons">
                      <i class="material-icons add">add</i>
                      <i class="material-icons remove">remove</i>
                    </span>
                  </span>
                {/if}
                {$node.label}
              </a>
              {if $node.children|count}
              <div {if $depth === 0} class="popover sub-menu js-sub-menu collapse"{else} class="collapse"{/if} id="top_sub_menu_{$_expand_id}">
                {menu nodes=$node.children depth=$node.depth parent=$node}
                {if $node.image_urls|count}
                  <div class="menu-images-container">
                    {foreach from=$node.image_urls item=image_url}
                      <img src="{$image_url}">
                    {/foreach}
                  </div>
                {/if}
              </div>
              {/if}
            </li>
        {/foreach}
      </ul>
    {/if}
{/function}

<div class="menu js-top-menu hidden-md-down" id="_desktop_top_menu" data-more={l s='more' d='Shop.Theme.Catalog'}>
    {menu nodes=$menu.children}
</div>
>

 

 thanks a lot for your attention , help me please if you have any tips on how to add a popover in those plus submenu to show subcatégory

image.png

×
×
  • Create New...