Ok let's troubleshoot this, because it worked for me without a problem. I want this to be useful to everyone, so I want to know what is going on here. Its so weird that it would work on one page but not others, but we have seen some signs that Discuss can be a bit quirky.
If we work at it and get very clear about it, we can get some support from someone. But we have to be very clear on exactly what the problem is.
First off, pls make sure your pages validate: validator.w3.org/ if there are errors, then all bets are off.
Second, pls use precisely the code I provide below, which works on my site. If we can get it to work, then you can play with it to get exactly what you want.
Call this snippet on your front page, main forum page, and on the update profile page. In addition, pls make a new resource (page), apply the relevant template, and put nothing in the contents except for the snippet call. That way we can get an idea about where it works and where it doesn't. If it only works on some pages it will help us troubleshoot.
Ok, make this snippet called Discuss.Threadsviews:
<?php
//POST SETTINGS BELOW
$show_posts = '0'; //Set to 1 if you want to show posts
$posts_last_added = '0'; //Set to 1 if you want to show last added posts
$posts_dynamic = '0'; //Set to 1 if you want to show dynamicly posts from current board
//THREADS SETTINGS BELOW
$show_threads = '1'; //Set to 1 if you want to show threads
//SELECT ONLY 1 OF 3 OPTIONS BELOW
$threads_last_posted = '0'; //Set to 1 if you want to show lastly active threads
$threads_most_viewed = '1'; //Set to 1 if you want to show most viewed threads
$threads_most_reply = '0'; //Set to 1 if you want to show threads with most reply's
$order = 'DESC'; //Set ASC for A->Z or DESC for Z->A
$limit = '5'; //Set limit count for results outputed which to be showed
$letters_limit = '30'; //Set letters limit for description of posts messages
$user_real_name = '1'; //Set to 1 if you want to show First Last names, set to 0 for username
//DONT EDIT BELOW THIS LINE
//COPYRIGHT RIMOTEVST KANEV
//DONT EDIT BELOW THIS LINE
//Build main sql querys
if($show_threads == '1'){
$c = $modx->newQuery('disThread');
}else{
$c = $modx->newQuery('disPost');
}
//Set filters
if(($show_posts == '1') AND ($posts_last_added == '1')){
$c->sortby('createdon',$order);
}else{}
if(($show_threads == '1') AND ($threads_last_posted == '1')){
$c->sortby('post_last_on',$order);
}else{}
if(($show_threads == '1') AND ($threads_most_viewed == '1')){
$c->sortby('views',$order);
}else{}
if(($show_threads == '1') AND ($threads_most_reply == '1')){
$c->sortby('replies',$order);
}else{}
if($show_threads == '1'){
//Exclude private threads
$c->where(array(
'private' => '0',
));
}else{
//If we are in main board page
if((strip_tags($_GET['board']) != '') AND ($posts_dynamic == '1')){
$c->where(array(
'board' => strip_tags($_GET['board']),
));
}else{}
//If we are in thread page
if((strip_tags($_GET['thread']) != '') AND ($posts_dynamic == '1')){
$t = $modx->newQuery('disThread');
$t->where(array(
'id' => strip_tags($_GET['thread']),
));
$t->limit(1,0);
$boards = $modx->getCollection('disThread',$t);
foreach ($boards as $board) {
$c->where(array(
'board' => $board->get('board'),
));
}
}else{}
}
//Set limits
$c->limit($limit,0);
//Get the Collections fetchResults
if($show_threads == '1'){
$resources = $modx->getCollection('disThread',$c);
}else{
$resources = $modx->getCollection('disPost',$c);
}
//Start of output array
$output = '';
//Looping to fill the output
foreach ($resources as $res) {
if($show_threads == '1'){
$output .= '<li class="rthread"><a href="forums/thread/'.$res->get('id').'/'.strtolower($res->get('title')).'">'.$res->get('title').'</a>';
$a = $modx->getObject('disUser', array('id' => $res->get('author_first')));
$output .= ' by <a class="rauthor" href="forums/u/'.$a->get('username').'/">';
if($user_real_name == '1'){
$output .= $a->get('name_first').' '.$a->get('name_last').'</a>';
}else{
$output .= $a->get('username').'</a>';
}
$output .= '</li>';
}else{
$output .= '<li class="rpost"><a href="forums/thread/'.$res->get('thread').'/'.strtolower($res->get('title')).'#dis-post-'.$res->get('id').'">'.$res->get('title').'</a>';
$output .= '<p>'.mb_substr($res->get('message'), 0, $letters_limit).'</p>';
$a = $modx->getObject('disUser', array('id' => $res->get('author')));
$output .= ' by <a class="rauthor" href="forums/u/'.$a->get('username').'/">';
if($user_real_name == '1'){
$output .= $a->get('name_first').' '.$a->get('name_last').'</a>';
}else{
$output .= $a->get('username').'</a>';
}
$output .= '</li>';
}
}
//Print the output
return $output;
Then, use this snippet call:
[[!Discuss.Threadsviews]]
Finally, feed me back on what is going on, or better, put all this in there and let me go to the site and check it myself.
Again, if there are underlying errors and the page won't validate, those have to be fixed first, there is just too much uncertainty when there are underlying errors.
Ok, pls let me know, we can work this out with some effort.