We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14677
    • 54 Posts
    Hey guys,

    Been banging my head against the wall recently as I am trying to move away from using the default Articles author pages in favor of some custom resources.

    I have setting some extended fields which contains a "uid" with the value or the resource id. I then used the following code in the top of my "ArticlesRowTpl" chunk.

    [[!Profile? &user=`[[!+createdby]]` &prefix=`user.` &useExtended=`true`]]
    <!-- [[!+createdby]] - [[+user.uid]] - [[~[[+user.uid]]]] -->

    [[!+createdby]]
    Returns the correct user id for each blog post

    [[+user.uid]]
    Returns the correct resource id for the first blog post and then the same id for all other blog posts

    [[~[[+user.uid]]]]
    Same as above but returns a url as required

    I am not sure why it doesn't get the users details for each respective user and instead only get's it for the first blog post.

    I would appreciate any help possible with this please.

    Many thanks,
    Jonathan [ed. note: jonrawlins last edited this post 10 years, 8 months ago.]
      • 3749
      • 24,544 Posts
      The createdby tag is uncached, so try making the other tags uncached:

      [[!+user.uid]]

      [[~[[!+user.uid]]]]

      The second one might have to be one of these:
      [[!~[[!+user.uid]]]]

      [[!~[[+user.uid]]]]
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 14677
        • 54 Posts
        Thanks Bob, unfortunatly I have tried these previously and they didn't work. It's really odd. It's almost like it parses the first then caches for the rest. That is the impression I get, and no matter what I change it just will not output all the others.
          • 3749
          • 24,544 Posts
          Caching can get kind of funky when you have a snippet whose properties are tags that's inside a chunk that's being used in an iteration by yet another snippet. Sometimes the placeholders are just not set at the time you need them.

          What, exactly, is in user.uid? Is it the ID of a Bio page for the user?
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 14677
            • 54 Posts
            Hi Bob, sorry for the delay in responding, I was away over the weekend and out of the office with meetings yesterday so haven't had a chance to reply.

            Basically user.uid holds a resource id which is a users bio page. If it links through to the bio page then it will display their Bio, blog's and Twitter / Google Plus buttons etc.
              • 14677
              • 54 Posts
              I've actually gone down the route of using the following for the time being (zip isn't used for our users in any other aspect).

              [[If?
                 &subject=`[[+createdby:userinfo=`zip`]]`
                 &operator=`empty`
                 &then=`<a href="[[~[[*id]]]]author/[[+createdby:userinfo=`username`]]">[[+createdby:userinfo=`fullname`]]</a>`
                 &else=`<a href="[[~[[+createdby:userinfo=`zip`]]]]">[[+createdby:userinfo=`fullname`]]</a>`
              ]]


              It will default to the standard MODx author page and if it has been set it will go through to their bio pages.

              Many thanks for your help.
                • 3749
                • 24,544 Posts
                What you're doing is probably much faster than using an extended field. As long as you don't need the zip field for anything else, it's a great solution.
                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting