WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Templates, Menus & Design => Topic started by: ircsurfer on August 12, 2010, 12:29:05 PM

Title: Show_Menu2 - Menu
Post by: ircsurfer on August 12, 2010, 12:29:05 PM
working on a menu, can be viewed at http://dev.ezweb4less.com/test/ (http://dev.ezweb4less.com/test/).

If you click on any of the top menu links you will see that the lower menu stays expanded to the next page down.

Problem is if you click on product 1 under manufacturer a, instead of just getting the warranty and tech info pages for that page only, i get the warranty and tech info pages for the product 2 showing also.

Have wrapped my head around this for hours now and maybe i just need to walk away from it.

The SM2 is show_menu2(2, SM2_ROOT, SM2_CURR+1, SM2_ALL, SM2_ALL);

Thanks for any help
Title: Re: Show_Menu2 - Menu
Post by: mjm4842 on August 12, 2010, 05:22:16 PM
Hi ircsurfer,

Your question is much better and clearer. I really appreciated the example you created which helped me reproduce the problem and come up with a solution which will hopefully meets your requirements.

The most obvious problem has to do with the number of parameters you specified. No worries, I have made this mistake myself on several occasions and it has often sent me troubleshooting for hours. Now it's always the first thing I check when things don't seem to be working as expected.

Start by merging your fourth and fifth parameters. According to the documentation:

Code: [Select]
    show_menu2(
        $aMenu          = 0,
        $aStart         = SM2_ROOT,
        $aMaxLevel      = SM2_CURR+1,
        $aOptions       = SM2_TRIM,   <-- SEPARATE OPTIONS HERE USING A | CHARACTER
        $aItemOpen      = '[li][a][menu_title]</a>',
        $aItemClose     = '</li>',
        $aMenuOpen      = '[ul]',
        $aMenuClose     = '</ul>',
        $aTopItemOpen   = false,
        $aTopMenuOpen   = false
)

For $aOptions, specifying this parameter is optional however if you are going to use it, you must specify exactly one option from GROUP 1 and any number of options from GROUP 2, separating them by a pipe (|), not a commas (,). For more information on the available options in each group, see the documentation.

To avoid ending up with unrelated branches expanding at the same level as in your example, replace the SM2_ALL with the SM2_TRIM option.

TIP: For the purpose of troubleshooting, I highly recommend you also apply the SM2_PRETTY option which will nicely format your HTML and make it easier for you to understand what is going on when you make a change

Give this line a try:

  show_menu2(2, SM2_ROOT, SM2_CURR+1, SM2_TRIM|SM2_PRETTY);

Hope this helps!

With warmest regards,


Michael Milette

___________________________
TNG Consulting Inc.
Provinding Sustainable Solutions for Life
www.tngconsulting.ca (http://www.tngconsulting.ca)
Title: Re: Show_Menu2 - Menu
Post by: ircsurfer on August 12, 2010, 06:59:35 PM
See, i had already achieved that with using the basic show_menu2(2); and i know that the SM2_all is causing it but i have tried many different combinations and nothing seems to work.

Maybe, i described my issue incorrectly.

What i have now in the lower menu when manufacturer A - Product 1 is clicked is the following
  Manufacturer A
     Product 1
          Warranty
          Technical Info
     Product 2
          Warranty
          Technical Info
     Product 3
Manufacturer B
     Product 1
     Product 2
     Product 3
Manufacturer C
     Product 1
     Product 2
     Product 3




What you should see in the lower menu when manufacturer A - Product 1 is clicked is the following
Manufacturer A
     Product 1
          Warranty
          Technical Info
     Product 2
     Product 3
Manufacturer B
     Product 1
     Product 2
     Product 3
Manufacturer C
     Product 1
     Product 2
     Product 3
Title: Re: Show_Menu2 - Menu
Post by: mjm4842 on August 12, 2010, 07:59:58 PM
Well, it's not exactly the same results you got from show_menu(2) but it's close.

You will need to use Conditional Formatting to achieve your goal. It's in the documentation. What this allows you to do is to create conditions under which menu items will appear.

For example, you might want to tell it not to display items lower than level 2 unless your current level is in a parent-sibling relationship of the current page.

TIP: When experimenting with show_menu2, don't rely on the results displayed in the browser. Always check the source code to see how your change affected the code.

Did you know? 80% of people don't even try to achieve their goals because they don't think they can do it. Out of the the remaining 20%, which you are a part of, 80% will quit not realizing just how close they actually were to succeeding. That leaves only 4% of all people who actually succeed in achieving their goals simply because they took action and didn't give up. Don't give up, you are almost there!

Oh, one more thing. When you do finally succeed, and I am sure you will, be sure to take time to really celebrate your success. You will have earned it.

Best regards,

Michael
Title: Re: Show_Menu2 - Menu
Post by: ircsurfer on August 15, 2010, 03:34:01 AM
Thanks for getting me to take a few steps back and think about this. I cannot take any credit whatsoever as the information was already available.

just needed to take a peak at the demo site and read it a bit carefully.

Title: Re: Show_Menu2 - Menu
Post by: mjm4842 on August 15, 2010, 04:05:27 AM
Excellent! Glad I could help.

Michael