TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

April 19, 2024, 08:44:47 PM

Login with username, password and session length
Members
  • Total Members: 3,885
  • Latest: Growner
Stats
  • Total Posts: 195,165
  • Total Topics: 21,219
  • Online today: 266
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 1
  • Guests: 196
  • Total: 197
  • tino

Recent Topics "Most Viewed" Block Code

Started by jernatety, March 09, 2019, 12:25:26 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jernatety

Thanks to Mick he got me situated with my block code. Works perfectly.

I do have a question though. It's currently coded to show most viewed topics. Is there a way to make it show all most recent topics with views over 1000? I only want the most viewed topics from one board "board=85.0"

This is the current code.

$array = ssi_topTopicsViews(15,'array');

foreach ($array as $topic) {

echo

$topic['link'];

echo '
<div align="center"><a href="', $topic['href'], '">', $news['subject'], '</a><hr></div>';


}

tino

That already orders based on views and uses the internal SSI functionality.

You can edit that and change it so that it looks for > 1000 views.

Find this;


$request = $smcFunc['db_query']('', '
SELECT id_topic
FROM {db_prefix}topics
WHERE num_' . ($type != 'replies' ? 'views' : 'replies') . ' != 0' . ($modSettings['postmod_active'] ? '
AND approved = {int:is_approved}' : '') . '
ORDER BY num_' . ($type != 'replies' ? 'views' : 'replies') . ' DESC
LIMIT {int:limit}',
array(
'is_approved' => 1,
'limit' => $num_topics > 100 ? ($num_topics + ($num_topics / 2)) : 100,
)
);


Change to


$request = $smcFunc['db_query']('', '
SELECT id_topic
FROM {db_prefix}topics
WHERE num_' . ($type != 'replies' ? 'views' : 'replies') . ' >= 1000' . ($modSettings['postmod_active'] ? '
AND approved = {int:is_approved}' : '') . '
ORDER BY num_' . ($type != 'replies' ? 'views' : 'replies') . ' DESC
LIMIT {int:limit}',
array(
'is_approved' => 1,
'limit' => $num_topics > 100 ? ($num_topics + ($num_topics / 2)) : 100,
)
);

jernatety

Hi Tino,

What Mick gave me is the exact code I have in the block. I didn't edit or change any files. I don't want to change the existing SSI.php file. I only want to put code in the block to find what I'm looking for.

Is that possible?

lurkalot

Quote from: jernatety on March 10, 2019, 03:36:51 PM

What Mick gave me is the exact code I have in the block. I didn't edit or change any files. I don't want to change the existing SSI.php file. I only want to put code in the block to find what I'm looking for.

Is that possible?

By the way, that's Mick as in Mick, not Mick as in me = lurkalot  ;)  Yes I only pointed you to the code Mick posted here, https://www.simplemachines.org/community/index.php?topic=562032.msg3987280#msg3987280

Like I already said, if the ssi.php file won't do what you're asking then you'll have to modify it to suite. This has also been confirmed in that topic.

If you're worried about screwing something up in while editing that ssi.php file, just keep a copy of it safe somewhere, so you can put it back should you need to. 

jernatety

The current recent topics block uses what? SSI.php I presume? I don't want to change that. I want the the default recent topics to do as it currently does, posts the most recent posts. I have default recent topics in the top block on my front page.

I want the .php block in my left column on the front page to be completely different. I want that to provide only the top most recent results with more than 1000 views from only one forum on my site. So basically, I am looking for .php code exclusively for just that left column block.

I am probably not explaining it correctly.

jernatety

I have no problem paying somebody to write the code I need for that block.

tino

Quote from: jernatety on March 10, 2019, 03:36:51 PM
Hi Tino,

What Mick gave me is the exact code I have in the block. I didn't edit or change any files. I don't want to change the existing SSI.php file. I only want to put code in the block to find what I'm looking for.

Is that possible?

Yes you can take what is inside the existing ssi_topTopicsViews and what it calls then edit it as you see fit.

jernatety

I really don't have any idea what you guys are talking about. I downloaded the SSI.php file and edited it per Tino's first response. Then added that entire page code to my .php block. All that does is blow up my front page screwing everything up.

jernatety

This has been taken care of and does exactly what I was hoping. Thank you to all for taking a look and making suggestions.

@rjen

Cool. Would you mind sharing the final updated block code?
Running Latest TP on SMF2.1 at: www.fjr-club.nl