We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 13226
    • 953 Posts
    Does anyone know if it's possible to set a bespoke template for ID 1 (document tree = id 1) in wayfinder.

    I've tried messing around with "PHX" + "If" but have come to the conclusion that my knowledge of both is too limited.

    I would prefer to use "If" due to the problems associated with "Phx"

    If anyone could point me in the right direction, that would be great.

    Thanks for your time.

    This question has been answered by iusemodx. See the first response.

      • 20413
      • 2,877 Posts
      Wayfinder doesn't include PHx like Ditto:
      https://forums.modx.com/thread/45350/phx-template-variables-and-wayfinder#dis-post-261947

      Another method to try is a plugin set on OnParseDocument or a snippet:
      $check = $modx->getPlaceholder('wf.docid'));
      if ($check == '1'){
        $myLogic = 'abc';
      } else {
        $myLogic = '123';
      }
      $modx->setPlaceholder('myplaceholder', $myLogic);


      Code is just an idea...
        @hawproductions | http://mrhaw.com/

        Infograph: MODX Advanced Install in 7 steps:
        http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

        Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
        http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
        • 13428 ☆ A M B ☆
        • 1,031 Posts
        [*phx:input=`[+wf.docid+]`:eq=`1`:then=`xxx`:else=`yyy`*]


        That code should work with PHx plugin installed. It will be parsed outside of Wayfinder (that snippet does not has PHx build in - as mrhaw already said).

        input=`[+wf.docid+]` could be used to access other document properties with the use of the docfield input=`[+wf.docid+]`:docfield=`template` modifier. But caution: each docfield call would cause an extra DB call.
          • 13226
          • 953 Posts
          Thanks for the answers and your time, but by the looks of things this is more hassle than it's worth.

          I think I will drop this.
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            It should be possible to use the "first" class to have customized CSS for the first item. An example of what you have in mind would be helpful.
              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
              • 13226
              • 953 Posts
              @ sottwell

              Thanks for the interest.

              The class has nothing to do with this situation - I need a bespoke template for the ID 1

              But I have canned the idea, thanks anyway for your time.
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                My point is, it's all in the CSS. You don't need a "bespoke template" when you can simply do some fancy CSS on a given element via classnames or ID attributes.

                The only time I can imagine really needing a specific HTML structure is in the case of some odd javascript functionality. In such a case, you can always simply put the link to resource #1 before the Wayfinder call, and have it not processed by Wayfinder normally, either by its Hide from Menus checkbox or the Wayfinder property &excludeDocs. Use CSS to position it where you need it in relation to the rest of the menu.
                  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
                  • 13226
                  • 953 Posts
                  Quote from: sottwell at Nov 10, 2013, 12:53 PM
                  you can always simply put the link to resource #1 before the Wayfinder call, and have it not processed by Wayfinder normally......the Wayfinder property &excludeDocs

                  This has put me on a different route - thanks

                  My thinking was too complex.

                  Simply removing it from the output is a great solution.

                  Adding it manualy using the required code and a little "If" snippet magic should do the rest

                  Thanks again

                  p.s. will have a go in the morning - will report back when done.
                  • discuss.answer
                    • 13226
                    • 953 Posts
                    UPDATE:

                    Couldn't wait to try the solution in my head so it ended up being a late night.

                    First of all, thanks for guiding the way on this - always nice to be able to do some brainstorming / bounce ideas & solutions around the forum.

                    The end solution uses a combo of "If" & "GetField" as shown below:

                    The main Wayfinder call now excludes ID = 1
                    &excludeDocs=`1`

                    Wayfinder Outer Tpl now includes a bespoke element for ID = 1

                    The "&outerTpl" template chunk now looks like this:
                    <ul>
                    [[if? &is=`[*id*]:is:1` &then=`MyBespokeCodeHere` &else=`<li><a href="[(site_url)]">[[GetField? &docid=`1` &field=`menutitle`]]</a></li>`]]
                    [+wf.wrapper+]
                    </ul>


                    Just to make sure theres no misunderstanding:

                    The chunk code above is not the end result, it simply demos how to accomplish what I have done.

                    I have removed my bespoke coding and CSS, as it's not necessary to show in this demo code.