$query->where(array('width:!=' => 15));
//Build main sql querys if($show_threads == '1'){ $c = $modx->newQuery('disThread'); }else{ $c = $modx->newQuery('disPost'); $c->where(array('messages:!=' => '0' )); }
[2014-09-17 16:36:23] (ERROR @ /index.php) Error 42S22 executing statement: Array ( [0] => 42S22 [1] => 1054 [2] => Unknown column 'disPost.messages' in 'where clause' )
That means you just want to get some Thread information of a post?!
Then look at line 145 in my example.
Here I get the thread of my post and then you can ask it for his private flag ...
$thread = $modx->getObject('disThread', array('id' => $res->get('thread'))); $thread_is_private = $thread->get('private');
Or am I wrong? tongue
[[!Discuss.LastPosts? &limit=`10`]]
<?php /* * * Lasts posts (default, 3) * * */ if (!(isset($limit))){ $limit = 3; } $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; $query = $modx->newQuery('disPost'); $query->limit($limit); $query->sortby('createdon', 'DESC'); $resources = $modx->getCollection('disPost', $query); //Start of output array $output = ''; if ($resources) { foreach ($resources as $res) { $extrait = 'title="'.mb_substr($res->get('message'), 0, $letters_limit).'" '; $output .= '<a ' . $extrait . ' href="forums/thread/'.$res->get('thread').'/'.strtolower($res->get('title')).'#dis-post-'.$res->get('id').'">'.$res->get('title').'</a>'; $a = $modx->getObject('disUser', array('id' => $res->get('author'))); $output .= ' par '.$a->get('username'); $date = $res->get('createdon'); $date = strftime(', %A %d %B %Y à %H:%M',strtotime($date)); //french date, comment to EN $output .= $date . ' <br />'; $output .= '<hr />'; //print_r($res->toArray()); //debug } } else { $output = 'No data !'; } return $output;
[[!Discuss.LastThreads? &limit=`10`]]
/* * * Last threads (default, 3) * */ if (!(isset($limit))){ $limit = 3; } $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; $query = $modx->newQuery('disThread'); $query->limit($limit); $query->sortby('post_last_on', 'DESC'); $resources = $modx->getCollection('disThread', $query); //Start of output array $output = ''; if ($resources) { foreach ($resources as $res) { $a = $modx->getObject('disUser', array('id' => $res->get('author_last'))); $username = $a->get('username'); $output .= '<a href="forums/thread/'.$res->get('id').'/'.strtolower($res->get('title')).'">'.$res->get('title').'</a>'; $output .= ' par : ' . $username; $date = $res->get('post_last_on'); $date = strftime(', %A %d %B %Y à %H:%M',strtotime($date)); //french date, comment to avoid $output .= $date . ' <br />'; //$output .= $res->get('post_last_on'); $output .= '<hr />'; //print_r($res->toArray()); //debug } } else { $output = 'no data'; } return $output;
<?php //POST SETTINGS BELOW $show_posts = '1'; //Set to 1 if you want to show posts $posts_last_added = '1'; //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 //////////////////////////////////////////////// $multi_posts = '1'; //Set to 1 if you want to show posts from exact thread $posts_ids = Array(107,106); //Set this for threads from which you want to show posts //THREADS SETTINGS BELOW $multi_boards = '1'; //Set to 1 if you want to show threads from exact boards $boards_ids = Array(107,106); //Set this for boards from which you want to show threads ////////////////////////////////////////////// $show_threads = '0'; //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 = '10'; //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'){ if($multi_boards == '1'){ foreach($boards_ids as $bid){ $c->where(array( 'OR:board:=' => $bid, 'AND:private:=' => '0', )); } }else{ //Exclude private threads $c->where(array( 'private' => '0', )); } }else{ if($multi_posts == '1'){ foreach($posts_ids as $pid){ $c->where(array( 'OR:board:=' => $pid, )); } }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;