We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 46220
    • 66 Posts
    The error I get now is:

    Fatal error: Call to a member function stripAllTags() on a non-object in /var/www/gcmodx/core/components/discuss/model/discuss/disthread.class.php on line 696

    Which is line 13 in the underneathstanding code:

        /**
         * Always ensure that the title strips any HTML/MODX tags
         * @param string $k
         * @param string|null $format
         * @param string|null $formatTemplate
         * @return mixed
         */
        public function get($k, $format = null, $formatTemplate= null) {
            $v = parent::get($k,$format,$formatTemplate);
            switch ($k) {
                case 'title':
                    $v = html_entity_decode($v);
                    $v = $this->xpdo->discuss->stripAllTags($v);
                    $v = strip_tags($v,'<span>');
                    $v = preg_replace('@\[\[(.[^\[\[]*?)\]\]@si','',$v);
                    break;
                default: break;
            }
            return $v;
        }


    Anyone that can help?

    Strangely enough the forums do work, just any other (non forum) page on the website shows this error.
      • 3749
      • 24,544 Posts
      Do you have any Discuss-related tags in a template that's used for non-Discuss pages?
        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
        • 46220
        • 66 Posts
        Yes I have, or at least, I assume I have them when creating content described in http://forums.modx.com/thread/91207/popular-threads-and-featured-threads#dis-post-500072. Which seemed to be working fine by the way.

        EDIT 1: If you look at http://gc.haulehuisje.nl/forums/, on the left side you see popular threads and latest posts. These are chunks within templates.

        EDIT 2: Ok, after the previous edit, I decided to take steps back in my process. I deleted one of the chunks:
        <p>[[!Discuss.Popular]]</p>

        Now it turns back to normal. So it has something to do with a piece of code somewhere. Probably not this piece of code, but the one it refers to:
        <ol>
        <li> 
        <h5><a href="/forums/thread/[[+thread]]/[[+threadname]]#dis-post-[[+post]]">[[+title]]</a></h5>
        <p style='margin-top:-15px'>[[+message:strip:stripTags:ellipsis=`50`]]</p>
                            <div class="clear"></div>
        </li>
        </ol>

        Any suggestions? [ed. note: gormytorysh last edited this post 9 years, 10 months ago.]
          • 46220
          • 66 Posts
          It could also be in this piece of code....:

          <?php
          $weghalen = array(",", "/", "?", "<", ">", ";", ":", "[", "]", "{", "}", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "+", "=");
          $vervangen = array(" ", ".");
           
          $c = $modx->newQuery('modUser');
          $c->leftJoin('modUserProfile','Profile');
          $c->sortby('id','ASC');
          // add column names that u want to show
          $c->select(array(
              'modUser.*',
              'Profile.fullname',
              'Profile.email',
          ));
            
          $users = $modx->getCollection("modUser",$c);
          $naam[0] = 'Anoniem';
          foreach($users as $user){
              $usr = $user->toArray();
           
          $naam[$usr['id']] = $usr['username'];
          $email[$usr['id']] = $usr['email'];
          }
           
          $tpl = $modx->getOption('tpl',$scriptProperties,'Forumthreads.Popular');
           
          $package_path = $modx->getOption('core_path').'components/discuss/model/';
          $modx->addPackage('discuss', $package_path);
          $vraag = $modx->newQuery('disThread');
          $vraag->sortby('replies','DESC');
          $vraag->where(array(
          ));
          $vraag->limit(5,0);
           
          $regels = $modx->getCollection('disThread',$vraag);
          $output = '';
           
          foreach($regels as $regel){
          $rglArray['post']= $regel->get('id');
          $rglArray['thread']= $regel->get('thread');
          $titel = strtolower($regel->get('title'));
          if(substr($titel, 0,4)=="re: "){$titel = substr($titel,4);}
          $titel= str_replace($vervangen, "-", str_replace($weghalen, "", $titel));
          if(substr($titel,-1)=="-"){$titel = substr($titel,0,-1);}
          $rglArray['threadname'] = $titel;
          //$rglArray['threadname'] = $titel2;
          $rglArray['title']= $regel->get('title');
          $rglArray['message']= $regel->get('message');
          $rglArray['author'] = $naam[$regel->get('author')];
          $rglArray['createdon']= $regel->get('createdon');
          $rglArray['gravatar'] = "http://www.gravatar.com/avatar/".md5(strtolower(trim($email[$regel->get('author')])))."?d=mm&s=50";
          $rglArray['email'] = $email[$regel->get('author')];
          $rglArray['nummer'] =$nummer;
           
          $output .= $modx->getChunk($tpl,$rglArray);
          }
          return $output;
          • In the snippet, instead of this:

            $package_path = $modx->getOption('core_path').'components/discuss/model/';
            $modx->addPackage('discuss', $package_path);


            do this:

            $package_path = $modx->getOption('core_path').'components/discuss/model/';
            $modx->getService('discuss', 'Discuss', $package_path);


            That will load Discuss as a service instead of just loading the model, and should resolve your fatal error.
              Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

              Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
              • 46220
              • 66 Posts
              Many thanks Mark! Error is gone now, it doesn't return a result on the main page like it does in the forum page, but will try to figure it out.
                • 46886
                • 1,154 Posts
                Yeah why would it not have output when on the front page, but does when inside the forums? Its getting Discuss as a service, as Mark said, so why would it matter what page we were on?

                It must not be accessing the Discuss data properly, or it should be fine to provide contents on the front page.