We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38004
    • 96 Posts
    hi, I'm considering using discuss for a new build as oppose to PHPBB.

    Is it possible to pull a feed of latest posts from a discuss forum for display on any modx page?

    How SEO friendly is it?

    Thanks
      • 42602
      • 81 Posts
      Yes it is doable and would say there is no effect on SEO, if there would be then 90% of the sites I follow would have bad SEO doe to having "recent ****" lists.

      This snippet should return 10 most posts (did not try it out but it is pretty straight forward)
      <?php
      $discuss = $modx->getService('discuss','Discuss',$modx->getOption('discuss.core_path',null,$modx->getOption('core_path').'components/discuss/').'model/discuss/');
      if (!($discuss instanceof Discuss)) return true;
      
      $c = $modx->newQuery('disPost');
      $c->where(array('private' => 0));
      $c->limit(10);
      $c->orderby('createdon', 'DESC');
      
      $posts = $modx->getCollection('disPost', $c);
      
      foreach ($posts as $post) {
          $temp = $post->toArray();
          $temp['url'] = $post->getUrl();
          // call chunks or what you want
          $out[] = $modx->getChunk('rowTpl', $temp);
      }
      return implode("\n", $out);
      
        • 46886
        • 1,154 Posts
        I tried this code but it didn't seem to work, throws an error.
          • 3749
          • 24,544 Posts
          What error are you getting?
            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
            Hi BobRay thanks for the message!

            Pls hold that thought for just a little while, I have been trolling the old forum threads, there are two scripts floating around to do this, and the other one (by mintnl) probably works.

            I will be trying both of these out next week, after I get a couple other things taken care of. At that time, I would love input from an expert like you.

            To be able to insert dynamic forum data into a page is the most awesome thing. It was always one on my main goals. If one of these works, its very, very big, because once the injection is possible then its open to such a wide range of different forum contents. I could fill a front page full of the latest posts, hottest threads, most liked and editor's picks, dynamically. That would be a dream.

            So, thanks again and I will post about this issue again very soon.
              • 46220
              • 66 Posts
              Quote from: BobRay at Apr 24, 2014, 10:40 PM
              What error are you getting?

              I don't know about nuan88's error, but this is what I am getting:

              Fatal error: Call to undefined method xPDOQuery_mysql::orderby() in /var/www/gcmodx/core/cache/includes/elements/modsnippet/92.include.cache.php on line 13
                • 46886
                • 1,154 Posts
                Yes that's the error I got as well, and it prevents the page from being created.