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

    In some cases I want users names to link to their Channels.

    I am trying to do this as below.

    Im storing a custom Vanity URL location in an extended field.

    Then using the if snippet to say, "If the URL doesn’t exist in the extended field, then just show the username, else, show the username as a link to the channel location."

    Yet this isnt working. Any guidance appreciated.

    By: [[!If?
       &subject=`[[+createdby:userinfo=`channelLocation`]]`
       &operator=`EQ`
       &operand=``
       &then=`[[+createdby:userinfo=`username`]]`
       &else=`<a rel="nofollow" href="http://domain.com/[[*createdby:userinfo=`channelLocation`]]">[[+createdby:userinfo=`username`]]</a>`
    ]]
      • 27716
      • 126 Posts
      BUMP!

      Can anyone see what im doing wrong here?

      [[+createdby:userinfo=`channelLocation`]] Is this going to work at all? Or off base?

      Any guidance appreciated smiley
        • 33968
        • 863 Posts
        I think your modifier is ok. For starters, try:
        &operator=`isempty`
        

        and remove &operand=`` (although I guess that should work anyway).

        And forgive me if this is too basic, but [[+createdby..]] is a placeholder for receiving the output of a snippet, whilst [[*createdby...]] will grab the ’createdby’ field for the current displayed resource. You have both in there, is that intentional?


        Unless I misunderstood, you might be able to do away with ’If’ and achieve it this way (not tested though tongue):
        [[*createdby:userinfo=`channelLocation`:notempty=`<a rel="nofollow" href="http://domain.com/[[*createdby:userinfo=`channelLocation`]]">[[*createdby:userinfo=`username`]]</a>`]]
        

        Try both and see which is quicker!
          • 33968
          • 863 Posts
          Hi mate, looked into this further - have you added ’channelLocation’ to modx_user_attributes? I don’t think it will work otherwise.

          Here’s a list of the default attributes for user info:
          http://www.shawnwilkerson.com/modx-revolution/tips-and-tricks/modx-filters.html
            • 27716
            • 126 Posts
            Hi Shawn,

            Thanks for your assistance,

            I havent added it to user attributes. I am trying to use the user extented fields. Going to try the code you provided now and see if I can get something to work.

              • 33968
              • 863 Posts
              I’m not Shawn - I barely know php smiley

              Sorry it took me a while to figure out what you were doing. I think to get access to those extended fields you’ll need to run a simple snippet first to output them to placeholders. Have a look at this post here (see responses #2 and #4).