Quote from: gormytorysh at Jun 02, 2014, 02:50 PM
I actually have 2 questions for now (see gc.haulehuisje.nl for visual support):
1. is it possible to get the most popular threads into the sidebar?
2. is it possible to mark threads as featured (and remove it when I want), and show into the sidebar?
Just looking at my first post, number 1 is partially solved and number 2 hasen't been answered yet (so I wonder why this thread is labeled answered
). To break down the issues in number 1:
- The output is shown in the forums page in the sidebar, but not on any non-forum page.
- When you click on one of the listed items, nothing happens, so there must be an error somewhere in the coding.
- It should be a top 5 and they are all labeled is 1. So I tried things in my CSS and looked at the code generated and as far as I can see, it is creating a new ordered list for every item in the output. So could this be in the code?
Just to support the above, here's the things I have right now:
The snippet:
<?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->getService('discuss', '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;
The 1st chunck:
<div id="side-top ol">
<div id="side-top ol li">
<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>
</div>
</div>
The 2nd chunk:
<h3>Popular Threads</h3>
<p>[[!Discuss.Popular]]</p>
And finally the CSS bit:
#side-top ol {padding:0 0 0 40px;list-style-type: decimal;border-bottom:1px solid #313030}
#side-top ol li {color: #fff;}
#side-top ol li a {color: #B0B0B0}
Any pointers would be again most welcome!!