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
//-------------------------
$topic_created = strtotime('-1 days'); // ADD THIS
//-------------------------
Scroll to the bottom of the file.
$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
$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
<?php echo $ubbt_lang['POPULAR_TOPICS'] ?>
and change to
<?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

Enjoy !