Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Nov 2003
Posts: 329
Beta Tester
Beta Tester
Offline
Joined: Nov 2003
Posts: 329
Custom Islands.

More and more news websites are presenting the topics of interest in various ways and they are eye catching.

We have Popular Topics
But its very static as popular get more popular if there in a visible list. If this became Popular topics today or this week then its would be more interesting to use and follow.

Most Read : Today / This Week
Would in my opinion be a good addition to the Post islands.

Most Replied : This Week
Would also engage users and members to get involved.

I cant do advanced code so I wonder if the idea could gain any momentum ?


BOOM 7.6.+ rocks....
Sponsored Links
Joined: Nov 2003
Posts: 329
Beta Tester
Beta Tester
Offline
Joined: Nov 2003
Posts: 329
Yeahhhh I got it to work smile

Very easy and frustrating to know that a dead duck feature is now very active again.

Ive set mine up to look up 1 day.
I'm sure there is a more "1 day" way of doing this but hey ho.

Find file
/cache_builders/popular_topics.php


PHP Code

<?php
// Script Version 7.5.8

if (!defined('UBB_MAIN_PROGRAM')) {
exit;
}
//-------------------------
$topic_created = strtotime('-1 days'); // ADD THIS
//-------------------------
// Need to move this into the config
$limit = 10;

// Exclude forums?
$notin = "";
if (
$config['EXCLUDE_POPULAR']) {
$notin = "and f.FORUM_ID not in ({$config['EXCLUDE_POPULAR']})";
}
// end if

$query = "
SELECT t.TOPIC_SUBJECT, t.TOPIC_VIEWS, t.POST_ID
FROM
{$config['TABLE_PREFIX']}TOPICS t,
{$config['TABLE_PREFIX']}POSTS p,
{$config['TABLE_PREFIX']}FORUMS f,
{$config['TABLE_PREFIX']}USERS u
WHERE 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
AND t.TOPIC_CREATED_TIME >=
$topic_created
$notin
ORDER BY t.TOPIC_VIEWS DESC
LIMIT
$limit
"
;
$sth = $dbh -> do_query($query,__LINE__,__FILE__);
$topics = array();
$i = 0;
while(list(
$sub,$views,$pid) = $dbh -> fetch_array($sth)) {
$topics[$i]['subject'] = $sub;
$topics[$i]['views'] = $views;
$topics[$i]['post'] = $pid;
$i++;
}
// end while

$smarty->assign("topics",$topics);

$island = $smarty->fetch("island_popular_topics.tpl");

lock_and_write("{$config['FULL_PATH']}/cache/popular_topics.php",$island);

@
chmod("{$config['FULL_PATH']}/cache/popular_topics.php",0666);

?>




Ive added these two lines

PHP Code
//-------------------------
$topic_created = strtotime('-1 days'); // ADD THIS
//-------------------------


PHP Code
AND t.TOPIC_CREATED_TIME >= $topic_created // ADD into the SQL Query 

Use the control panel settings to tweak the Excluded Forums and Cache time.


BOOM 7.6.+ rocks....
Joined: Nov 2003
Posts: 329
Beta Tester
Beta Tester
Offline
Joined: Nov 2003
Posts: 329
Part 2 weekly Most popular (well last 7 days).
And Ive hijacked a existing island so cache is still valid and working. And you can control the cache time from the control panel.

Whats involved ?

We hijack Top Posters island as its static and boring.
We add a New Language text for the island.
Update the Language file so Top posters is renamed to Weekly Popular.
We duplicate and exiting tpl file and add a tiny tweak.

* * * * * * * * * *
NOTICE : I'm no expert on this so will say its probably can be improved on but Its above my pay grade lol.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

You can do this Live if you do not have "Top Posters Island" on view.

1. find /cache_builders
2. Look for the following files.

popular_topics.php (its the file from my first hack above).
top_posters.php

make a backup of top_posters.php

Open both files and copy the contents from popular_topics.php into top_posters.php

We need to edit a couple of lines in top_posters.php


Change the -1 to -7
Code
//-------------------------
$topic_created = strtotime('-1 days'); // ADD THIS
//-------------------------

Scroll to the bottom of the file.

Code
$smarty->assign("topics",$topics);

$island = $smarty->fetch("island_popular_topics.tpl");

lock_and_write("{$config['FULL_PATH']}/cache/popular_topics.php",$island);

@chmod("{$config['FULL_PATH']}/cache/popular_topics.php",0666);

change to

Code
$smarty->assign("topics",$topics);

$island = $smarty->fetch("island_popular_topics_week.tpl");

lock_and_write("{$config['FULL_PATH']}/cache/top_posters.php",$island);

@chmod("{$config['FULL_PATH']}/cache/top_posters.php",0666);

Close and Save.

3. Next we create a new tpl file.

Navigate to templates/default
find island_popular_topics.tpl

copy and paste to make a new file called island_popular_topics_week.tpl

You should now have these two files

island_popular_topics_week.tpl
island_popular_topics.tpl

open up the island_popular_topics_week.tpl

we need to modify 1 line in there for the language file update.

find
Code
<?php echo $ubbt_lang['POPULAR_TOPICS'] ?>
and change to
Code
<?php echo $ubbt_lang['POPULAR_TOPICS_WEEK'] ?>

save and close

Make sure your do not have "Top Posters" island active just yet.

Upload the files as there are only changes in the control panel to make now.


UBB Control panel.

language editor search for popular and then click on edit (it should land you at portal_islands.php)

Dont copy and paste the text from POPULAR_TOPICS as it will kill your island as its not parsing in to the language editor properly but this is the work around.

at the bottom empty spaces

KEY
POPULAR_TOPICS_WEEK
Description just put a . (Full stop).
Then update and it will update with out an issue.
You can now copy and paste the similar text from the POPULAR_TOPICS description field and update.

Almost there.

Control panel Portal Layout. Over to the right side click on External view.
It will probably show the original top posters.
Clear the cache.
Go back and click on external view and you should now see the weekly most viewed topics.


FINAL
is just house work really.
Portal Settings update the cache setting for "Top posters"
Language file editor do searches to edit the control panel display from "Top Posters" to "Weekly most popular".

I think that's all of it.

* You can modify the island files in the cache builders to change the limits on how many should be visible for faster or slower forums.

Why re invent the wheel when its been half done.


G !
Feel free to tidy this post / topic smile

Enjoy !


BOOM 7.6.+ rocks....
Joined: Jan 2000
Posts: 5,833
Likes: 20
UBBDev / UBBWiki Owner
Time Lord
UBBDev / UBBWiki Owner
Time Lord
Joined: Jan 2000
Posts: 5,833
Likes: 20
thumbsup


UBB.Dev - Putting Dev into UBB.threads
Company: VNC Web Services - UBB.threads Scripts and Scripting, Install and Upgrade Services, Site and Server Maintenance.
Forums: A Gardeners Forum, Scouters World, and UGN Security
UBB.Threads: My UBB Themes, My UBB Scripts
Joined: Dec 2001
Posts: 87
Power User
Power User
Joined: Dec 2001
Posts: 87
thumbsup thumbsup


Bill Barker
Issaquah, Wa
Sponsored Links
Joined: Nov 2003
Posts: 329
Beta Tester
Beta Tester
Offline
Joined: Nov 2003
Posts: 329
Im please to confirm this works with 7.6.1.1 (patched).

I'ts been a while as you can see from the date I added this one with my limited knowledge.

Ive added a few Language File Tweaks I have made, this may confuse or simplify for you ?
For me it simplified as I could follow.

Code


Most Read (Views 24hrs).

Language Files
Search - change - KEY
Search "Popular Topics" change to "Most Read" (POPULAR_TOPICS)
Search "Popular Topics" Change to "Views 24hrs" (POPULAR_TOPIC VIEWS)
Search "Popular Topics" change to "Popular Topics (24hrs)" (popular_topics)
Search "Popular Topics" change to "Exclude Popular Topics (24hrs) In These Forums" (POPULAR)
Search "Popular Topics" change to "Popular Topics (24hrs)" (popular_topics)

---
Most Read (Views 7days)
language File Search "Popular Topics" (portal_islands.php)
create a new KEY (POPULAR_TOPICS_WEEK) and new STRING "Popular Topics"

create POPULAR_TOPICS_VIEWS_WEEK and a new STRING "Views 7days"

I hope one day that this could find its way into a stock release wink

The beauty with this is that you can select and de-select the forums to be show,

The one thing i could not work out ?

Moving a listed topic in the 24hr island. It would show up twice with a count starting from zero.
So i would make sure the link would be deleted in 24hrs..
Not sure how to get around that one .....
If you move without leaving a pointer its just fine.

Enjoy
Attachments
popular-7days.PNG (65.02 KB, 13 downloads)
popular-24hrs.PNG (32.6 KB, 13 downloads)

Last edited by Mark_S; 01/15/2018 12:01 PM.

BOOM 7.6.+ rocks....

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
isaac
isaac
California
Posts: 1,157
Joined: July 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)