We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 47717
    • 144 Posts
    Hi,

    When one clicks on "option1" in the site-menu, that "option1" is saved for all the other pages and that value is processed in the template output.

    When one clicks on "option2" in the menu, that value is saved also, and generates even after clicking on dozens of other pages, still a slghtly different template output.

    However I do not know how to solve this.

    Any help would be welcome

    thanks [ed. note: sriananda last edited this post 10 years, 8 months ago.]
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      I'm sorry, your description of your problem is not clear.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 47717
        • 144 Posts
        Quote from: sottwell at Feb 01, 2016, 04:02 PM
        I'm sorry, your description of your problem is not clear.

        ok Sottwell,
        sorry for that. If you have tips so I can express a problem more clearly, I would be glad for the feedback.

        There are 50 productpages.
        They have a submenu in the sidebar, which lists the clickable products in 2 ways:
        1. per supplier
        2. per product type

        The main menu on the top has the usual buttons (home, contact, ...) and a "our products" which has a submenu:
        1. per supplier
        2. per product type

        So when "per supplier" is clicked, all 50 separate productpages , have the special ordering in the sidebarmenu "per supplier".
        When "per product type" is clicked, all 50 html productpages have a different ordering in the sidebar menu.

        So the question is, how can I register a "global value", after clicking on those 2 options, that is used as a conditional input for the wayfinder/getresources links in the sidebar menu of the product template?

        regards,
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          There are several ways to accomplish something like that. You could use a cookie or the SESSION, or add the value to a query string.

          With that value available in a cookie or the SESSION or the GET, you can use a wrapper snippet to get the value then run the Wayfinder or pdoMenu using runSnippet() with the sorting based on the value.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 47717
            • 144 Posts
            Quote from: sottwell at Feb 02, 2016, 02:48 AM
            There are several ways to accomplish something like that. You could use a cookie or the SESSION, or add the value to a query string.

            With that value available in a cookie or the SESSION or the GET, you can use a wrapper snippet to get the value then run the Wayfinder or pdoMenu using runSnippet() with the sorting based on the value.

            Thank you for your input.

            That was something I already knew how to the with the snippet "getUrlParam".

            But I would like to make another "modx setting"-global variable, that can have a value "a" or "b".

            If I click in the menu on "by product type", a custom php snippet is run, and that "modx setting" value is immediately changed to "a".

            So for other templates, that [[++custom_setting]] value is used, as input for an "if statement" to show another sidebar.

            I am grateful for any input.


              • 3749
              • 24,544 Posts
              Changing the value is relatively simple (assuming that you've created the Setting):

              $setting = $modx->getObject('modSystemSetting', array('key' => 'custom_setting'));
              if ($setting) {
                  $setting->set('value', 'newValue');
                  $setting->save();
              } else {
                  $modx->log(modX::LOG_LEVEL_ERROR, 'Setting ' . 'custom_setting' . ' not found');
              }
              


              Use a System Setting (as shown above) if you want the value to be available for all users. You can also use a User Setting or a Group Setting that will affect only individual users or members of a User Group. I would start with a System Setting, no matter what, then change it once it's working if you want a User or Group setting.

              Changing the value with a click would typically be done with JavaScript that uses an Ajax call that sends the new value to a processor containing the code above (plus a section to get the new value and return success or failure indicators.

              It's somewhat easier to do it with a form and no JS, but the page will reload.



                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 47717
                • 144 Posts
                Thanks for your input.

                I will try them out asap ! smiley