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

    Im pretty new at modX, so im still getting used to everything.
    But lately i jumped out in doing some Discuss. And trying to intergrate the thing more and more to the homepage..

    But now i have ended up in a problem, so here is the question:!

    How do i used [[+discuss.config.url]]in my banner chunk, Or in a Themplate Variable.
    Here are my progress so far, and also where my problem is http://galtarian.net-fabrikken.dk/

    I hope one of you have an answer to me, because i been looking for ages now smiley

    And im sorry for my poor English smiley

    Best regards
    Nquitty [ed. note: nquitty last edited this post 9 years, 9 months ago.]
      • 39404
      • 175 Posts
      stalemate resolution associate Reply #2, 9 years, 9 months ago
      Nquitty,

      I found another post similar to this:
      http://forums.modx.com/thread/81547/using-anchor-link-while-on-discuss

      I've never used Discuss, but in this post, Mark suggests using what you suggested or [[+discuss.url]]


      Hope this helps.

      Regards,
      Tom
        • 3749
        • 24,544 Posts
        I think the value of that placeholder is generated on the fly by Discuss. If that's the case, the only way to get it may be to instantiate Discuss in a snippet and call the method that produces it (I think it's $discuss->make->url()), or borrow the code from Discuss and modify it for use in a custom snippet of your own.

        See also: $discuss->getUrl();




        [ed. note: BobRay last edited this post 9 years, 9 months ago.]
          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
          I had another thought.

          You should be able to get the posts themselves with:

          $c = $modx->newQuery('disPost');
          $c->limit(20);
          $posts = $modx->getCollection('disPost', $c);


          You may have to load the discuss class first, but I don't think so.

          Once you have the posts, you should be able to do something like this:

          $output = '';
          foreach($posts as $post) {
              $url = $post->getUrl();
          
              $fields = $post->toArray();
              $fields['discuss.config.url'] = $url;
              $output .= $modx->getChunk('myTpl', $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
            • 46886
            • 1,154 Posts
            [[+discuss.config.url]] doesn't work? That's what is in the wrapper.tpl, which has the forum template.

            This value is configured in system settings, as discuss.forums_resource_id which probably means it can be output using that placeholder.

            I just have it hardcoded as <a href="[[~20]]">, I don't think this value will change anytime soon.
              • 46886
              • 1,154 Posts
              Now that I think about it, that system setting will be used by the url maker. If the code above doesn't work, then that would be another example where people have trouble getting discuss stuff onto their front page, its a little weird sometimes and has given some fits.

              The url maker in my mind seems like it shouldn't be that tough, that its not an elegant setup, but in the discuss templates its used all the time, so I must be wrong. smiley
                • 48414
                • 3 Posts
                So far the answers have been good, but it's not in the end what i look for. I'll try to come with another example smiley, using one of the templates

                [[%discuss.users_active? &total=`[[+activeUsers.total]]`]]: This turns out to be discuss.users_active: But in the normal template it turns out to be "Active Users (18):" AKA im not getting the same result as in the base discuss tpl's I don't know why and this is what i really need help to figure out ^^
                  • 46886
                  • 1,154 Posts
                  Yeah I follow you, I see that the data isn't getting there.

                  I will put more of the code from the wrapper.tpl at bottom here, so people can see what is supposed to happen.

                  First thing that isn't happening is that its not registering what word strings it should be getting, [[%discuss.stats]] should return a word or words. The second thing not appearing is the data itself.

                  For both of these, I wonder how you converted or integrated the wrapper.tpl file into your design? Did you just cut out the header into your original template? Do you have all the lines from the head area of the wrapper.tpl? Especially watch out for the LAB file and scripts...and this line seems super important:

                  <body id="forumbody-[[+controller.controller]]" class="forums[[+discuss.user.id:notempty=` a-loggedin`]]">


                  I have seen similar problems before, but I don't know precisely what causes it. Can you get the output on any page? Or do all your pages have the same problem?

                  Here is the data from the footer of wrapper.tpl:
                   <strong class="m-stats-title">[[%discuss.stats]]</strong>
                                  </div>
                                  <div class="f2-f3 m-stats">
                                      <strong class="m-stats-title">Total:</strong>
                                      <ul>
                                          <li>[[%discuss.posts]]: <span>[[+totalPosts]]</span></li>
                                          <li>[[%discuss.threads]]: <span>[[+totalTopics]]</span></li>
                                          <li>[[%discuss.members]]: <span>[[+totalMembers]]</span></li>
                                      </ul>
                                  </div>
                                  <div class="f4-f5 m-stats">
                                      <strong class="m-stats-title">Online:</strong>
                                      <ul>
                                          <li>Visitors: <span>[[+totalVisitorsActive]]</span></li>
                                          <li>Members: <span>[[+totalMembersActive]]</span></li>
                                      </ul>
                                  </div>
                                  <div class="f6-f7 m-stats">
                                      <strong class="m-stats-title">Today:</strong>
                                      <ul>
                                          <li>Visitors: <span>[[+activity.visitors]]</span></li>
                                          <li>[[%discuss.threads]]: <span>[[+activity.topics]]</span></li>
                                          <li>[[%discuss.replies]]: <span>[[+activity.replies]]</span></li>
                                      </ul>
                                  </div>
                                  <div class="f8-f12 m-stats-live">
                                      <div class="m-stats-group">
                                          <strong class="m-stats-title">[[%discuss.users_active? &total=`[[+activeUsers.total]]`]]:</strong>
                                          <span class="m-stats-single">[[+activeUsers.users]]</span>
                                      </div>
                    • 48414
                    • 3 Posts
                    Well to answer you nuan88.
                    First of all, yes i have copied the scripts into the head, with the LAB.
                    Then i have copied the content of "wrapper.tpl" footer, and placed it in a chunk, with my own footer, Then I did the same with the header.

                    I have done the same with the Header so far as well.

                    and the problem is on all pages, also the forum page


                    Tho if i remove it from my own tpl's header, and move it into the wrapper again.. Then right away it works

                    Now i added, [[Discuss]] In the top and it loads everything fine.. ok a few things not but most.. I don't get this Discuss :p [ed. note: nquitty last edited this post 9 years, 9 months ago.]
                      • 46886
                      • 1,154 Posts
                      How about that line I asked about, you got this one?

                      <body id="forumbody-[[+controller.controller]]" class="forums[[+discuss.user.id:notempty=` a-loggedin`]]">


                      If you have that line in there, then I think what might be happening is this: the page is rendered, and after discuss does its thing the chunk comes in, and its coming in too late to be connected with discuss...

                      My suggestion is take it out of a chunk and leave it directly in the template, that may be the difference. and if any other pieces are in chunks, try to put them into the template and see what happens.