We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37108
    • 80 Posts
    I'm finding a need to be able to view a menu of items created by wayfinder to be visible during the editing phase, but before the documents have been published. From what I've searched on, there's no property to make this happen. Ideally, there would be a setting to allow wayfinder to see these items only while logged into the manager as a manager user. So, two questions:


    • Is this possible and relatively simple to implement?, and
    • Would others find this proposed feature useful as well?

    Thanks for your input!
      • 32316
      • 387 Posts
      As far as I know your research is correct, there is no way to include unpublished documents.

      However you can use getResources to create a menu that includes unpublished resources ( &showUnpublished=`1` )

      Of course if you purpose is to view what a wayfinder menu will look like before publishing a resource on a live site this will probably not help. In this case you just have to publish / view / unpublish and be quick about it!

      Might be a good feature to request.
        • 36404
        • 307 Posts
        hi,

        well, two little things, one of them obvious smiley
        - if you want wayfinder to "see" a doc you'll have to save it first even if as unpublished or, but i'm sure you know that, it wont' be found out in the db

        - depending on how your wayfinder call ignoreHidden parameter is set, if it's set on false (the default value) great, make another call where you set it on true and publish your page but uncheck the see in menu.
        this way, you'll be able to have two wayfinder call one if your logged as manager that "sees" the hidden from menu pages and the other not (easy to achieve depending on session vars)

        have swing
          réfléchir avant d'agir
        • That should be easy enough to add, it's hardcoded to make sure a doc is published right now.

          https://github.com/splittingred/Wayfinder/blob/develop/core/components/wayfinder/wayfinder.class.php#L582
                      $c->where(array('modResource.published:=' => 1));


          Could replace with
          if (!$modx->getOption('includeUnpublished',$this->_config,false)) {
                        $c->where(array('modResource.published:=' => 1));
          }
          

          and pass includeUnpublished=`1` into your Wayfinder call.

          Can you file it as a feature request? https://github.com/splittingred/Wayfinder/issues
            Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

            Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
            • 37108
            • 80 Posts
            Thanks for the replies! Ultimately, I'm really going for a setting that allows WF to see the unpublished documents only when a manager session is active ( similar behavior to how a single unpublished page is viewable by clicking "View" in the manager - or entering the URL into the browser having the active manager session ). This would be either proposed as a hard-coded change in the WF class or as a switchable system setting. Going under the assumption that your front end users are never going to have manager access and you don't want them to see unpublished items in menus, this would allow prototyping pre-published resources/menus without having to toggle settings.
              • 37108
              • 80 Posts
              I just added the feature request, including a proposed solution for a change at line 580 (/core/components/wayfinder/wayfinder.class.php).

              /* show unpublished when logged into manager */
              if(!$this->modx->user->isAuthenticated('mgr')){
                  $c->where(array('modResource.published:=' => 1));
              }
              
              • Would be nice to add the link to your FR tongue

                The trouble with that fix is that if you call the Wayfinder call is cached (like it should be..!) and view the site as a manager that will be cached... so others will see it too wink

                IMO, a viewUnpublished setting would be a better idea so you can decide it based on the call.
                  Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

                  Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
                  • 37108
                  • 80 Posts
                  Yes, but adding a setting/parameter to a call is just too cumbersome. It's a pain for a developer and just plain asking for trouble if you have a client going in and switching call paramaters back and forth. Thanks for pointing me toward the cache issue, I'd not thought of that ... will think it through some more! Could it work to conditionally make the query uncached when user is logged in and make it dynamic (i.e., cache dependent on the call itself) otherwise?
                  • You could uncache the menu and use your fix, but Wayfinder is a heavy snippet and that would come at a cost of processing time.
                      Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

                      Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
                      • 4955
                      • 32 Posts
                      Hi,
                      hope it's ok to warm up this old post but there is one scenario where at least for us it would make sense to get the unpublished items: we are running online courses and one module consists of 10 units. Each week a unit is published. To let our student see how many weeks / units they survived and how much they still have to work on it would be great to get also the unpublished items to be displayed in the navigation bar. Any new ideas how to achieve this?
                      Thanks a lot for feedback.
                      Best,
                      c--