Previous Thread
Next Thread
Print Thread
Hop To
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. laugh

Joined: Jun 2006
Posts: 16,299
Likes: 116
UBB.threads Developer
UBB.threads Developer
Joined: Jun 2006
Posts: 16,299
Likes: 116
Ok, a tip/sugguestion; look at the top posters island and craft accordingly?


I am a Web Development Contractor, I do not work for UBBCentral. I have provided free User to User Support since the beginning of these support forums.
Do you need Forum Install or Upgrade Services?
Forums: A Gardeners Forum, Scouters World
UBB.threads: UBBWiki, UBB Styles, UBB.Sitemaps
Longtime Supporter & Resident Post-A-Holic
VNC Web Services: Code Modifications, Upgrades, Styling, Coding Services, Disaster Recovery, and more!
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.


- Allen
- ThreadsDev | PraiseCafe
Joined: Apr 2007
Posts: 3,940
Likes: 1
SD Offline
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 laugh

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 wink

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) wink

Joined: Apr 2007
Posts: 3,940
Likes: 1
SD Offline
Former Developer
Former Developer
Joined: Apr 2007
Posts: 3,940
Likes: 1
here's a quickie. this should get you real close..

PHP Code

<?php
/* PHP CODE HERE */
# by SD
#
# Okie dokie, i figure some peeps might think that a 'Hot Topic' is more 'hot'
# by fact that it has more Replies vs Views, so there is an option here
#
# Simply change to 'Views' for using topic views or 'Replies' if you think replies count more ;)
#
# Also, since this puppy is a cached dealio, you might want to limit which forums are part of
# the query. ie: you prolly don't want to include that super secret "Gizmo can't see this forum"
# in your returned list

$whichHot = 'Views';
$notIn = '9';											// if you want more, just seperate by commas. ie: '4,5,9,10'
$limit = 10;											// Set to 10 topics, but you can change to whatever

$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";

// First, let's get an HTML table started.. m'kay ?
$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>';

// Set up the query
$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++;
}

// Check if we got any rows at all
if (!innerds) {
$stuff = '[censored] nothing found! :eek:';
} else {
$stuff .= $innerds.'</table>';
}
/* BODY HERE */
$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
SD Offline
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 laugh


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. wink

Joined: Apr 2007
Posts: 3,940
Likes: 1
SD Offline
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 smile

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,358
Y
Veteran
Veteran
Y Offline
Joined: Aug 2006
Posts: 1,358
Originally Posted by ScriptKeeper
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.


[Linked Image from siemons.org]
Joined: Apr 2007
Posts: 3,940
Likes: 1
SD Offline
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 wink

Joined: Dec 2006
Posts: 1,235
veteran
veteran
Joined: Dec 2006
Posts: 1,235
Damn, you guys are good. wink

Joined: Jul 2006
Posts: 4,057
Joined: Jul 2006
Posts: 4,057
Hey that looks pretty good wink

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 smile


BOOM !! Version v7.6.1.1
People who inspire me Isaac ME Gizmo
Joined: Jun 2006
Posts: 16,299
Likes: 116
UBB.threads Developer
UBB.threads Developer
Joined: Jun 2006
Posts: 16,299
Likes: 116
I was goinna just sugguest doing a str_replace to nuke the RE: but hey, sd's works too :x


I am a Web Development Contractor, I do not work for UBBCentral. I have provided free User to User Support since the beginning of these support forums.
Do you need Forum Install or Upgrade Services?
Forums: A Gardeners Forum, Scouters World
UBB.threads: UBBWiki, UBB Styles, UBB.Sitemaps
Longtime Supporter & Resident Post-A-Holic
VNC Web Services: Code Modifications, Upgrades, Styling, Coding Services, Disaster Recovery, and more!
Joined: Apr 2007
Posts: 3,940
Likes: 1
SD Offline
Former Developer
Former Developer
Joined: Apr 2007
Posts: 3,940
Likes: 1
Originally Posted by Mark S
Hey that looks pretty good wink

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 smile


with that skeleton, even YOU should be able to slam it in now wink

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
SD Offline
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 wink

Joined: Dec 2006
Posts: 1,235
veteran
veteran
Joined: Dec 2006
Posts: 1,235
x

Last edited by ScriptKeeper; 11/10/2007 8:41 PM. Reason: Unable to delete
Joined: Jun 2006
Posts: 16,299
Likes: 116
UBB.threads Developer
UBB.threads Developer
Joined: Jun 2006
Posts: 16,299
Likes: 116
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.


I am a Web Development Contractor, I do not work for UBBCentral. I have provided free User to User Support since the beginning of these support forums.
Do you need Forum Install or Upgrade Services?
Forums: A Gardeners Forum, Scouters World
UBB.threads: UBBWiki, UBB Styles, UBB.Sitemaps
Longtime Supporter & Resident Post-A-Holic
VNC Web Services: Code Modifications, Upgrades, Styling, Coding Services, Disaster Recovery, and more!
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,299
Likes: 116
UBB.threads Developer
UBB.threads Developer
Joined: Jun 2006
Posts: 16,299
Likes: 116
Lol good timing :x


I am a Web Development Contractor, I do not work for UBBCentral. I have provided free User to User Support since the beginning of these support forums.
Do you need Forum Install or Upgrade Services?
Forums: A Gardeners Forum, Scouters World
UBB.threads: UBBWiki, UBB Styles, UBB.Sitemaps
Longtime Supporter & Resident Post-A-Holic
VNC Web Services: Code Modifications, Upgrades, Styling, Coding Services, Disaster Recovery, and more!

Link Copied to Clipboard
ShoutChat
Comment Guidelines: Do post respectful and insightful comments. Don't flame, hate, spam.
Recent Topics
Bots
by Outdoorking - 04/13/2024 5:08 PM
Can you add html to language files?
by Baldeagle - 04/07/2024 2:41 PM
Do I need to rebuild my database?
by Baldeagle - 04/07/2024 2:58 AM
This is not a bug, but a suggestion
by Baldeagle - 04/05/2024 11:25 PM
Is UBB.threads still going?
by Aaron101 - 04/01/2022 8:18 AM
Who's Online Now
0 members (), 834 guests, and 246 robots.
Key: Admin, Global Mod, Mod
Random Gallery Image
Latest Gallery Images
Los Angeles
Los Angeles
by isaac, August 6
3D Creations
3D Creations
by JAISP, December 30
Artistic structures
Artistic structures
by isaac, August 29
Stones
Stones
by isaac, August 19
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20230217)