Previous Thread
Next Thread
Print Thread
Rate Thread
Most Read : Today / Week Most Replied This Week #320638
11/04/2014 10:37 PM
11/04/2014 10:37 PM
Joined: Nov 2003
Posts: 331
UK
M
Mark_S Offline OP

Beta Tester
Mark_S  Offline OP

Beta Tester
M

Joined: Nov 2003
Posts: 331
UK
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
Re: Most Read : Today / Week Most Replied This Week [Re: Mark_S] #320639
11/10/2014 4:09 AM
11/10/2014 4:09 AM
Joined: Nov 2003
Posts: 331
UK
M
Mark_S Offline OP

Beta Tester
Mark_S  Offline OP

Beta Tester
M

Joined: Nov 2003
Posts: 331
UK
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....
Re: Most Read : Today / Week Most Replied This Week [Re: Mark_S] #320640
11/15/2014 8:43 AM
11/15/2014 8:43 AM
Joined: Nov 2003
Posts: 331
UK
M
Mark_S Offline OP

Beta Tester
Mark_S  Offline OP

Beta Tester
M

Joined: Nov 2003
Posts: 331
UK
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....
Re: Most Read : Today / Week Most Replied This Week [Re: Mark_S] #320641
11/15/2014 2:08 PM
11/15/2014 2:08 PM
Joined: Jan 2000
Posts: 5,947
Portland, OR, USA
Gizmo Online tapedshut

UBB.Dev / UBB.Wiki Owner
Time Lord
Gizmo  Online Tapedshut

UBB.Dev / UBB.Wiki Owner
Time Lord

Joined: Jan 2000
Posts: 5,947
Portland, OR, USA
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, UBB.SitemapsJames Corthell
Re: Most Read : Today / Week Most Replied This Week [Re: Mark_S] #320642
11/20/2014 9:04 AM
11/20/2014 9:04 AM
Joined: Dec 2001
Posts: 84
Issaquah, WA
Bill B Offline
Power User
Bill B  Offline
Power User

Joined: Dec 2001
Posts: 84
Issaquah, WA
thumbsup thumbsup


Bill Barker
Issaquah, Wa
Sponsored Links
Re: Most Read : Today / Week Most Replied This Week [Re: Mark_S] #322929
01/15/2018 10:57 AM
01/15/2018 10:57 AM
Joined: Nov 2003
Posts: 331
UK
M
Mark_S Offline OP

Beta Tester
Mark_S  Offline OP

Beta Tester
M

Joined: Nov 2003
Posts: 331
UK
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

Attached Files
popular-7days.PNG (6 downloads)
popular-24hrs.PNG (6 downloads)
Last edited by Mark_S; 01/15/2018 11:01 AM.

BOOM 7.6.+ rocks....

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
· Blue Host
· Interserver.net
Visit us on Facebook
Member Spotlight
badfrog
badfrog
somewhere on the coast of Maine
Posts: 94
Joined: March 2007
Show All Member Profiles 
Forum Statistics
Forums64
Topics37,467
Posts293,523
Members13,802
Most Online1,498
Mar 17th, 2017
Top Posters(All Time)
AllenAyres 25,587
JoshPet 11,330
Rick 8,373
LK 7,396
Lord Dexter 6,503
Gizmo 5,947
Greg Hard 5,533
Top Posters(30 Days)
isaac 1
Today's Statistics
Currently Online 932
Topics Created 0
Posts Made 0
Users Online 2
Birthdays 14
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2018 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 7.7.0
(Snapshot build 20181115.dev)
PHP: 5.4.45 Page Time: 0.037s Queries: 16 (0.010s) Memory: 3.2116 MB (Peak: 3.5925 MB) Data Comp: Zlib Server Time: 2018-12-14 13:09:18 UTC