We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30912
    • 463 Posts
    I want to display a profile when a visitor clicks the author of the blog, presently they are sent to blog/author/userid instead of displaying all of the blogs I want to send a visitor to a web page which details that users profile based on their ID.

    any ideas how id go about this, as its a first for me smiley
      • 3749
      • 24,544 Posts
      Look in the Article template for some code that looks something like this (search for "Posted on"):

      <p class="post-info">
              <span class="left">Posted on [[*publishedon:strtotime:date=`%b %d, %Y`]] by <a href="[[~[[*parent]]]]author/[[*publishedby:userinfo=`username`]]">[[*publishedby:userinfo=`username`]]</a></span>
      [[*articlestags:notempty=`
              <span class="tags left"> | Tags: [[+article_tags]]</span>
      `]]
              [[+comments_enabled:is=`1`:then=` | <a href="[[~[[*id]]]]#comments" class="comments">Comments ([[+comments_count]])</a>`]]
          </p>



      You want to change this section of that code:

      <a href="[[~[[*parent]]]]author/[[*publishedby:userinfo=`username`]]">


      (I don't have the current version of Articles, so the details may be different, but it's the part inside the double quotes you want to change.

      You can make that href point anywhere you want. How you do it depends on whether you want to create a separate new resource with a profile for each author, or whether you want to use the Profile snippet (part of the Login extra) to show the author information, in which case you only need a single page.

      If you have separate pages, you can create a container document (not an Article) that will be a parent to the profile pages (let's say its ID is 12), put the profile pages below it in the tree, each one's pagetitle will be 'Author##', where ## is the author's ID.

      Then change the href to:

      <a href="[[~12]]/Author[[*publishedby]]">


      The publishedby field holds the ID of the user who published the resource. If that's not the author, you can use the createdby field.

      If you want to use the Profile snippet, you'd send everyone to the same page (again, let's say its ID is 12). For security, I would put a tag for a custom snippet (called SaveAuthorId) in that Article Template that writes the author's ID to a $_SESSION variable rather than exposing it as a parameter in the URL.

      [[!SaveAuthorId]]


      <?php
      /* SaveAuthorId */
      $_SESSION['AuthorId'] = $modx->resource->get('publishedby');
      return '';
      


      In that case, the href would look like this:

      <a href="[[~12]]">


      For the landing page (12), you can create a complimentary snippet to get the author ID from the $_SESSION variable:

      [[!GetAuthorId]]



      <?php
      return $_SESSION['AuthorId'];



      Then, you can use that in the Profile snippet tag like this:

      [[!Profile? &user=`[[!GetAuthorId]]`]]


      You'll have to put placeholders on the page for the various user fields you want to show. The Profile snippet will set placeholders for all fields in the user Profile and any extended fields as well if you add the &useExtended=`1` property to the tag.

      http://rtfm.modx.com/extras/revo/login/login.profile
        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
        • 30912
        • 463 Posts
        This is why you are a MODx God BobRay (and also why your book is awesome) I will have a crack at this and let you know the outcome.

        Thanks
          • 3749
          • 24,544 Posts
          Don't thank me until it works. wink
            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
            • 30912
            • 463 Posts
            Oh it works alright smiley a bit fiddly using the extended fields but it will do what is required.

            Thanks again for your help, be a good tutorial to add to articles when i get some free time.
              • 3749
              • 24,544 Posts
              Thanks for the kind words. I'll probably do a blog post on it myself.

              If you don't mind, what was fiddly about the extended fields?
                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
                • 30912
                • 463 Posts
                I have a contributors page set up which uses a MIGx TV to allow the user to edit the TV and profile, the extended fields dont have the facility for a rich text area that they can use with ease, its all raw HTML or paths.

                Trying to edit 3 paragraphs of text on a single line of an input field isnt easy, its not something thats a bit issue for me but i was thinking from a user perspective.

                its probably something to do with the way the extended fields are stored as JSON in the db, but i was thinking from a client perspective.
                  • 3749
                  • 24,544 Posts
                  I get it.

                  The extended fields are kind of a bastard add-on. They're difficult to search on and limited in what they can hold.

                  Maybe you could create a temporary location somewhere else (chunk, TV, or file) for the rich-text field and then write it to the extended field when saved.

                  One kind of crazy option is NewsPublisher. You could create a NewsPublisher configuration for editing a Resource, showing TVs for all the User Fields and nothing else. Then save everything where it really belongs in a plugin tied to OnDocFormSave.

                  I've thought of creating a NewsPublisher-like extra for editing the User Profile, with the option of rich-text extended fields.
                    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
                    • 3749
                    • 24,544 Posts
                    Quote from: BobRay at Aug 23, 2013, 11:10 PM
                    I get it.

                    The extended fields are kind of a bastard add-on. They're difficult to search on and limited in what they can hold.

                    Maybe you could create a temporary location somewhere else (chunk, TV, or file) for the rich-text field and then write it to the extended field when saved.

                    One kind of crazy option is NewsPublisher. You could create a NewsPublisher configuration for editing a Resource, showing TVs for all the User Fields and nothing else. Then save everything where it really belongs in a plugin tied to OnDocFormSave.

                    I've thought of creating a NewsPublisher-like extra for editing the User Profile, with the option of rich-text extended fields.
                      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