|
Joined: Dec 2006
Posts: 1,235
veteran
|
veteran
Joined: Dec 2006
Posts: 1,235 |
Is it possible to create a custom island by dragging info from the SQL tables? What I would like to do is have a Custom Island similar to the Top Posters that displays Top 5/10 Most Viewed Threads with 2 columns: Thread Title and Views in DESC order. Any tips, hints, pointers, etc. gladly accepted.
|
|
|
|
Joined: Jun 2006
Posts: 16,372 Likes: 129
|
Joined: Jun 2006
Posts: 16,372 Likes: 129 |
Ok, a tip/sugguestion; look at the top posters island and craft accordingly?
|
|
|
|
Joined: Dec 2006
Posts: 1,235
veteran
|
veteran
Joined: Dec 2006
Posts: 1,235 |
So, top_posters.php is in the cache_builders directory with the other standard islands. Do I create another in there (e.g. top_views.php) and link to it in a custom island somehow?
Just trying to get to grips with how this thing works.
|
|
|
|
Joined: Dec 2003
Posts: 1,796
Pooh-Bah
|
Pooh-Bah
Joined: Dec 2003
Posts: 1,796 |
For your custom island you'd put your php code in the top of the custom island and your html below, like most any other custom island. In this case you'd write code similar to the top_posters.php code and put it in the top of the custom island box with the html that prints the info below that.
|
|
|
|
Joined: Apr 2007
Posts: 3,940 Likes: 1
Former Developer
|
Former Developer
Joined: Apr 2007
Posts: 3,940 Likes: 1 |
i'd use the Yarp™ Birthday island as the example, since it is a real custom island. taking the top posters as an example helps you understand the php behind the scenes dealio, but the Bday one shows you where to put everything in a custom island. seems as if Custom islands are notorious for having stuff put in the wrong place at least with Yarp™'s, you could start from there and just change the sql crapola and then simply generate the table with your two columns into a variable (say $muhaha -- like he builds $bdays).. then slam the result between the EOF and voila if i find a spare 30mins, i can post the CI over @ ubbdev. it's not too hard to do for a ubb geek, but might be a tad pain in the arse otherwise (still totally doable and i encourage you going for it, if you'd like)
|
|
|
|
Joined: Apr 2007
Posts: 3,940 Likes: 1
Former Developer
|
Former Developer
Joined: Apr 2007
Posts: 3,940 Likes: 1 |
here's a quickie. this should get you real close..
<?php
$whichHot = 'Views';
$notIn = '9'; $limit = 10; $orderBy = ($whichHot == 'Views') ? ' t.TOPIC_REPLIES' : ' t.TOPIC_VIEWS';
$notIn = ($notIn) ? 'WHERE f.FORUM_ID NOT IN ('.$notIn.') ' : 'WHERE 1 ';
$timeFrame = $html->get_date() - 86400;
$timeFrame = "AND t.TOPIC_LAST_REPLY_TIME > $timeFrame";
$stuff = '<table cellspacing="0" cellpadding="0" border="0" class="t_standard">';
$stuff .= '<tr><td class="tdheader" width="80%">Topic subject</td><td class="tdheader" width="20%" align="center">'.$whichHot.'</td></tr>';
$query = "
SELECT p.POST_SUBJECT, t.TOPIC_VIEWS, t.TOPIC_REPLIES, t.POST_ID
FROM {$config['TABLE_PREFIX']}TOPICS t,
{$config['TABLE_PREFIX']}POSTS p,
{$config['TABLE_PREFIX']}FORUMS f,
{$config['TABLE_PREFIX']}USERS u
$notIn
$timeFrame
AND t.FORUM_ID = f.FORUM_ID
AND t.TOPIC_IS_APPROVED = 1
AND t.TOPIC_LAST_POST_ID = p.POST_ID
AND t.TOPIC_LAST_POSTER_ID = u.USER_ID
ORDER BY $orderBy DESC, t.TOPIC_LAST_REPLY_TIME DESC
LIMIT $limit
";
$sth = $dbh->do_query($query,__LINE__,__FILE__);
$innerds = '';
$rowNum = 0;
while(list($pSubj,$tViews,$tReplies,$tPostID) = $dbh->fetch_array($sth)) {
$count = ($whichHot == 'Views') ? $tViews : $tReplies;
$lineColor = ($rowNum&1) ? 'alt-topicsubject' : 'topicsubject';
$innerds .= '<tr><td class="'.$lineColor.'"><a href="'.$config['FULL_URL'].'/ubbthreads.php?ubb=showflat&Number='.$tPostID.'">'.$pSubj.'</a></td>';
$innerds .= '<td class="'.$lineColor.'" align="center">'.$count.'</td></tr>';
$rowNum++;
}
if (!innerds) {
$stuff = '[censored] nothing found! :eek:';
} else {
$stuff .= $innerds.'</table>';
}
$body = <<<EOF
$stuff
EOF;
?>
Didn't test real hard, since i was in a hurry.. but that should get you real close.. you can apply the finishing touches..
|
|
|
|
Joined: Apr 2007
Posts: 3,940 Likes: 1
Former Developer
|
Former Developer
Joined: Apr 2007
Posts: 3,940 Likes: 1 |
ps: paste all but the <?php and ?> into a spare /cache_builders/custom/portal_box_x.php pps: since this is a standard part of customizing your board, i figured i could post here. if not allowed, then quickly copy the code before this thread gets killed
|
|
|
|
Joined: Dec 2006
Posts: 1,235
veteran
|
veteran
Joined: Dec 2006
Posts: 1,235 |
Copied, thanks. I've been trying to work between Yarp's BDay code and the existing Top Posters code but not having much luck. Totally new to me all this stuff but I'm having a go anyway.
|
|
|
|
Joined: Apr 2007
Posts: 3,940 Likes: 1
Former Developer
|
Former Developer
Joined: Apr 2007
Posts: 3,940 Likes: 1 |
ok, i just tested it and it works.. one thing you might want to consider is to limit the subject length to a certain # characters. but for most part it's close to what you want
|
|
|
|
Joined: Dec 2006
Posts: 1,235
veteran
|
veteran
Joined: Dec 2006
Posts: 1,235 |
I've got it to work exactly as I wanted now, might need a little more tweaking, and I need to find if I can link to the topic without the "Re:" displaying.
|
|
|
|
Joined: Aug 2006
Posts: 1,360 Likes: 1
Veteran
|
Veteran
Joined: Aug 2006
Posts: 1,360 Likes: 1 |
I've got it to work exactly as I wanted now, might need a little more tweaking, and I need to find if I can link to the topic without the "Re:" displaying. Get the subject from the topics table.
|
|
|
|
Joined: Apr 2007
Posts: 3,940 Likes: 1
Former Developer
|
Former Developer
Joined: Apr 2007
Posts: 3,940 Likes: 1 |
change p.POST_SUBJECT to t.TOPIC_SUBJECT i think.. for the query.. and *poof* done
|
|
|
|
Joined: Dec 2006
Posts: 1,235
veteran
|
veteran
Joined: Dec 2006
Posts: 1,235 |
Damn, you guys are good.
|
|
|
|
Joined: Jul 2006
Posts: 4,057
|
Joined: Jul 2006
Posts: 4,057 |
Hey that looks pretty good Only problem is that the popular get popular if you get me. Nice if you could tweak to exclude certan topics. i.e. we have a general chit chat thread, half of the planet must have clicked on it (Joking) but you get it? Maybe Top 10 FAQ <Thinks> Pinning it to a individual forum that way the issues members have will be in the listings the most
BOOM !! Version v7.6.1.1 People who inspire me Isaac ME Gizmo
|
|
|
|
Joined: Jun 2006
Posts: 16,372 Likes: 129
|
Joined: Jun 2006
Posts: 16,372 Likes: 129 |
I was goinna just sugguest doing a str_replace to nuke the RE: but hey, sd's works too :x
|
|
|
|
Joined: Apr 2007
Posts: 3,940 Likes: 1
Former Developer
|
Former Developer
Joined: Apr 2007
Posts: 3,940 Likes: 1 |
Hey that looks pretty good Only problem is that the popular get popular if you get me. Nice if you could tweak to exclude certan topics. i.e. we have a general chit chat thread, half of the planet must have clicked on it (Joking) but you get it? Maybe Top 10 FAQ <Thinks> Pinning it to a individual forum that way the issues members have will be in the listings the most with that skeleton, even YOU should be able to slam it in now
|
|
|
|
Joined: Nov 2006
Posts: 3,095 Likes: 1
Carpal Tunnel
|
Carpal Tunnel
Joined: Nov 2006
Posts: 3,095 Likes: 1 |
Now Now - let's not be SLAMMING too much
Thanks for the great ideas and help you give SD
(you too Giz, but this one's for SD)
|
|
|
|
Joined: Apr 2007
Posts: 3,940 Likes: 1
Former Developer
|
Former Developer
Joined: Apr 2007
Posts: 3,940 Likes: 1 |
Mark S rawks, so no harm intended. i had added the smiley for phun factor.. actually i was trying to seque to the Geico / caveman commercials
|
|
|
|
Joined: Dec 2006
Posts: 1,235
veteran
|
veteran
Joined: Dec 2006
Posts: 1,235 |
x
Last edited by ScriptKeeper; 11/10/2007 7:41 PM. Reason: Unable to delete
|
|
|
|
Joined: Jun 2006
Posts: 16,372 Likes: 129
|
Joined: Jun 2006
Posts: 16,372 Likes: 129 |
The view count isn't updated when it's viewed; instead it puts an increase into a temporary table; once a post is made (anywhere) it updates the real incriment with what's in the temp table.
|
|
|
|
Joined: Dec 2006
Posts: 1,235
veteran
|
veteran
Joined: Dec 2006
Posts: 1,235 |
Sorry Gizmo I deleted my post before you replied after reading this thread.
|
|
|
|
Joined: Jun 2006
Posts: 16,372 Likes: 129
|
Joined: Jun 2006
Posts: 16,372 Likes: 129 |
|
|
|
1 members (mavorg),
180
guests, and
112
robots. |
Key:
Admin,
Global Mod,
Mod
|
|
|
|