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

    I have a page in my site (using MODxHost) and I want to link to an application form that has to be on an encrypted page. I have the certificate - and everything is working fine, but...

    How do I link to this from the menu button?

    Here’s the deal: I’m in the CMS on the document setting page. I wanted to put the https link into the Menu Title form field, but then it would show this whole title on the nav-menu button. How would I link to this from the nav-menu?

    Please see screenshot for better "visual explanation".

    THANKS smiley


    Cheers,
    Soren
      • 21496
      • 225 Posts
      Can’t you just create a Weblink?
        René
        • 28025
        • 50 Posts
        Hi Nightsignals,

        Stupid question: just how does that work... I know the feature is there but never how to use it (and the purpose)?

        Soren

          • 22303 MODX Staff
          • 10,725 Posts
          The problem is that the MODx url generation logic has no way to know which pages you want to serve as https. You might take a look at the Encryption snippet from the add-on repository as one possible solution.
            • 21496
            • 225 Posts
            Quote from: Soreng at Dec 02, 2007, 09:22 PM

            Hi Nightsignals,

            Stupid question: just how does that work... I know the feature is there but never how to use it (and the purpose)?

            Well, reading the answer of Jason, I’m not sure if it’s me being the stupid one here. If I understand you correctly, you want to have a menu pointing to a resource that’s available through https://....

            If you create a weblink instead of an ordinary document, you can insert the link there, and it shows up in your navigation like any other document. And since I don’t see where encryptions needs to come in here, I might not fully understand what you want to accomplish. I was thinking if you can access that application through an URL, that URL can be as well be in a weblink.
              René
              • 28025
              • 50 Posts
              Thanks guys - I will try this.

              First, I’ll be "playing" with creating a weblink (Nightsignal, you are not misunderstanding - it is the scenario you are explaining I want.)

              ganeshXL: good idea - I’ll take it for a spin and see which works.

              Thanks!
                • 22303 MODX Staff
                • 10,725 Posts
                ganeshXL’s example might work for you, but to further explain:

                All URL’s generated by Wayfinder and $modx->makeUrl() function (unless specifically passed parameters to tell it otherwise) will always use the scheme (http:// or https://) that was used in the accessing request. In order to handle this, you need something like the ill-named snippet I mentioned (easier to manage which specific pages get redirected), or a similar plugin to always redirect requests to pages intended to be secure, or in this case insecure...
                <?php
                /**
                 * SSLRedirect
                 * A MODx plugin to force requests to certain pages to an SSL version.
                 */
                if ($modx->event->name == 'OnWebPageInit') {
                    if (isset ($insecurePages)) {
                        $insecurePages= explode(',', $insecurePages);
                    } else {
                        $insecurePages= array ();
                    }
                    
                    if ($_SERVER['SERVER_PORT'] == 443 || (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS'])=='on')) {
                        if (in_array($modx->documentIdentifier, $insecurePages)) {
                            $modx->sendRedirect($modx->makeUrl($modx->documentIdentifier, '', '', 'http'));
                        }
                    } else {
                        if (!in_array($modx->documentIdentifier, $insecurePages)) {
                            $modx->sendRedirect($modx->makeUrl($modx->documentIdentifier, '', '', 'https'));
                        }
                    }
                }
                ?>

                This uses a comma-delimited list of document ID’s from the plugin configuration, meant to NOT be served with https:// (I chose this approach when I implemented this code, because a majority of the pages on the site where this was used have to be served with https:// ). But it could just as easily be adjusted to work the other way around.

                Note that this plugin is dependent on some makeUrl changes in 0.9.6.1 which allow you to specify the scheme as http or https specifically, in addition to the legacy approach using numeric values, or full.
                  • 28025
                  • 50 Posts
                  OpenGeek:

                  Thanks a lot! This leaves me with a couple of options. Excellent! I thank you for this!


                  Cheers,
                  Soren
                    • 28025
                    • 50 Posts
                    I tried ganeshXL’s example which works. The only "but" is, that I get the little popup window with "this page contains both secure and non-secure items..." + the lock icon doesn’t show when you do it this way (it does say https in the addr. bar, though)

                    What can be done to avoid this message and just go to a secure page?


                    Soren
                      • 28025
                      • 50 Posts
                      I’m not sure I understand... Where would I change that?

                      In that case - does that mean that the entire site will be secure and not just the respective pages?