We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12684
    • 118 Posts
    How do I write a link that will give 2 possibilities? If I want to send some of my web members to one page and others to another, how do I write the link out?

    For example:

    <a href="[~id#1~]">link name</a>


    How do I write that to include another page( [~id#2~] ), so that depending on the users authorization they will be sent to one or the other page?

      • 3707
      • 241 Posts
      You could use the MemberCheck snippet: http://modxcms.com/MemberCheck-541.html

      Or you could use PHx, something like:
      [+phx:mo=`myWebgroup`:then=`<a href="[~id#1~]">link name</a>`:else=`<a href="[~id#2~]">link name</a>`+]
        • 12684
        • 118 Posts
        Thank you,

        The PhX worked well. I am wondering now how to add a third link for if it is a guest and not logged in. I think I need to add a parameter for a default redirect page.
          • 12684
          • 118 Posts
          Figured it out by just adding another mo to the call:

          [+phx:mo=`myWebgroup`:then=`<a href="[~id#1~]">link name</a>`:mo=`myWebgroup2`:then=`
          <a href="[~id#2~]">link name</a>`:else=`<a href="[~id#2~]">link name</a>`+]


          *Spaced for fitting in the code window
            • 12684
            • 118 Posts
            Actually it does not work, nor do I see anything in the phx documentation that would help in setting a string for 3 different choices. Anyone know if this is possible?

              • 12684
              • 118 Posts
              Any one know the answer to this one?
                • 3707
                • 241 Posts
                I don’t think PHx can do this. I wanted to do something similar but PHx doesn’t have an elseif conditional. You could use nested PHx calls so that the first call checks one web group and displays one link. The else statement can call a chunk:
                [+phx:mo=`webGroupA`:then=`<a href="[~id#1~]">link name</a>`:else=`{{nextGroupCheck}}`+]

                In the {{nextGroupCheck}} chunk you can call PHx again to check the second web group and display two other links:
                [+phx:mo=`webGroupB`:then=`<a href="[~id#2~]">link name</a>`:else=`<a href="[~id#3~]">link name</a>`+]

                It might not the neatest way of doing it but it should work.
                  • 12684
                  • 118 Posts
                  One problem with this for me though. The original link is already in a Chunk. How do I call another Chunk inside of a Chunk.

                  I just have not learned that yet.
                    • 3707
                    • 241 Posts
                    I don’t think there is a problem with this. Have you tried it?
                      • 12684
                      • 118 Posts
                      Yes.
                      In one Chunk named Loginmenu I have the following:
                      <h2>Main</h2>
                      <ul>
                      <li><a href="http://www.site.com/">Home</a></li>
                      <li>[+phx:mo=`Vendors`:then=`<a href="[~40~]">My Account</a>`:else=`{{nextGroupCheck}}`+]</li>
                      <li><a href="[~43~]">Brides</a></li>
                      <li><a href="[~1~]">Calendar</a></li>
                      <li><a href="[~30~]">FAQ</a></li>
                      </ul>


                      In the nextGroupCheck Chunk I have:
                      [+phx:mo=`Registered Members`:then=`<a href="[~5~]">My Account</a>`:else=`<a href="[~2~]">Login</a>`+]