I am close to the end of phase 1 I just have just one more issue and I hope someone has the solution.
If you look at
http://gc.haulehuisje.nl/ one the sidebar, popular threads, it does not show anything. However, if you look at
http://gc.haulehuisje.nl/forums/ it does show it there, though my [OL] is not working correctly and the link is not showing properly and therefor not working. Anyone that has a suggestion?
The code I used was taken from mintnl's latest post with some adjustments already provided by others.
The snippet I use:
<?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;
Chunk 1:
<div id="side-top ol">
<div id="side-top ol li">
<ol>
<li>
<h5><a href="/forums/thread/[[+thread]]/[[+threadname]]">[[+title]]</a></h5>
<p style='margin-top:-15px'>[[+message:strip:stripTags:ellipsis=`50`]]</p>
<div class="clear"></div>
</li>
</ol>
</div>
</div>
Chunk 2 (the call):
<h3>Popular Threads</h3>
<p>[[!Discuss.Popular]]</p>
It would help me greatly if someone has a solution as I have been trying to get it to work for almost a week now and no results.