We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16834
    • 93 Posts
    Hello

    I am building a site of several hundred pages of which more than half are for registered users only.
    The dropdown menus look terrific and I am now starting to decide which pages are to be restricted. Using the default settings, Wayfinder is removing these pages from the public menu structure.

    I would like Wayfinder to display restricted pages in the menu structure in order that public visitors are aware of the additional information available. My wish is that the user clicks on the menu link and is requested to register.

    Is there a way of overriding the user-authority check? I cannot find a parameter that does so.

    Many thanks

    Leapy
      • 4310
      • 2,310 Posts
      If nobody comes up with a parameter to override the privateweb restriction you could hack the code.
      There are many reasons not to do this but if you have to, look in assets/snippets/wayfinder/wyfinder.inc.php around line 349.
      Change this =>
       // build query
      	        $access = ($modx->isFrontend() ? "sc.privateweb=0" : "1='{$_SESSION['mgrRole']}' OR sc.privatemgr=0").(!$docgrp ? "" : " OR dg.document_group IN ({$docgrp})");
      			$sql = "SELECT DISTINCT {$fields} FROM {$tblsc} sc LEFT JOIN {$tbldg} dg ON dg.document = sc.id WHERE sc.published=1 AND sc.deleted=0 AND ({$access}){$menuWhere} AND sc.id IN (".implode(',',$ids).") GROUP BY sc.id ORDER BY {$sort} {$this->_config['sortOrder']} {$sqlLimit};";

      To this =>
       // build query
      			$sql = "SELECT DISTINCT {$fields} FROM {$tblsc} sc LEFT JOIN {$tbldg} dg ON dg.document = sc.id WHERE sc.published=1 AND sc.deleted=0 {$menuWhere} AND sc.id IN (".implode(',',$ids).") GROUP BY sc.id ORDER BY {$sort} {$this->_config['sortOrder']} {$sqlLimit};";

      It removes the check for whether the document is private.
      The private document appears in the menu but when clicked the user is redirected to the unauthorized page.
      Make sure your unauthorised page in the site configuration is set to your register page.
      I’ve only tested this quickly on a single level menu.
      Backup the original file in case it goes belly up and you need to revert.
      Test it locally first if you can.

      Good luck wink
        • 16834
        • 93 Posts
        BOOM! smiley

        OK, thanks. I have a version of modx on a virtual machine, will try there first....

        Leapy
          • 16834
          • 93 Posts
          Hi David

          Very many thanks for the help. I appreciate the effort. The menu now displays exactly what I need.

          Thank heavens there are no doc groups that I would wish to keep hidden from my users. It would be terrific to be able to explicitly include certain Doc Groups in the Wayfinder call. Is Wayfinder actively developed at present?


          Lee
            • 4310
            • 2,310 Posts
            There are two parameters :
            &includeDocs
            &excludeDocs

            in the wayfinder.inc.php file but I’m not sure what they do exactly.
            I’ve tried them quickly, &excludeDocs seems to work but &includeDocs doesn’t seem to have any effect.
            I don’t think there’s been much recent development as it was pretty near perfect from the start!
              • 16834
              • 93 Posts
              Hi. I looked at the info about &includeDocs but, if it worked, it would require manual updating of docs to be included. Unfortunately, for my site, the documents are to be dynamically added to restricted doc groups and so this would not work.

              It is times like this that I wish I was a coder!

              Still, again, many thanks.

              Leapy
                • 16834
                • 93 Posts
                FOr those who are interested. I have posted a bounty request for this functionality to be added to Wayfinder.

                http://modxcms.com/forums/index.php/topic,28124.0.html

                Thanks

                Leapy