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

Recent

Welcome to TinyPortal. Please login or sign up.

April 16, 2024, 05:16:25 AM

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

Few blocks from TP causing my site to eat resources.

Started by Ricky., December 14, 2007, 07:26:52 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Ricky.

Hi, I was discussing this topic in SMF forum that my smf is eating a lot of resources.
Anyways, last night I just came to know that my INDEX page ie. TP index page is taking almost 5x more time in generation than any other becasue it has "RSS" blocks.

I used those RSS blocks to present latest 12 topics and its really useful. 1 is for same site and other is from other smf website running on same server.

Last night page creation time went high to 30 seconds.. woaah..
When I disabled both rss block.. it went down to 0.23 secs.

So, wht I am supposed to dO?
All I want to include latest topic started on front page with their actual URL but not url pointing to latest post on that topic.

Any idea.. how do I decrease server load in this case without sacrificing "Latest Topics STarted block" ?

PS: site is http://www.yoindia.com/shayariadab/

Zetan

I'm not sure why you are using RSS to pull information from around your site into a place of choice.
RSS should be used sparingly and is really meant for external content.

Have you looked into using SMF's built in SSI functions? There are many Block Code Snippets that can likely do what you need, additionally you can find examples of SSI functions on your own website.

http://yoursite.com/ssi_examples.php

and

/ssi_examples.shtml

Also try searching, you'll find many topics both here and at SMF about SSI.

Ricky.

#2
Hi,

I did gave extensive look on various options available.
Also looked into SSI from SMF.

SSI do have latest post function but problem is that its showing board also but I simply by one by one list of latest topics .Another poblem is that it leads to latest reply on that topic but I want it go to topic only..
Eg.
from

It leads to :
http://www.simplemachines.org/community/index.php?topic=210979.msg1342866;topicseen#new

But I want :
http://www.simplemachines.org/community/index.php?topic=210979.0

Here is SSI.php example from smf website itself.

Zetan

The title of this topic is misleading.. "Blocks from TP..."
Actually, from what you are saying, it's the Content Within the blocks that are causing the problem, not TP itself.

Have you actually looked in the Snippets board? I'm sure SSI can be used to do what you need, even if that means making a Request for some code to be altered.

G6Cad

Also want to add that RSS is something Bloc is working on to improve a bit more, it have some faults but will get better.
As ZTN say, there are snippets with both SSI and also PHP that will give you your content you have now with RSS

Ricky.

Ya I meant to say that "Content from some block in TP".

Well, I gave really good time to look into solution already given there. Well, again.. I am not able to find something similar.

All I need "list of latest 15 topics" with URL leading to real topic but not to latest post on that topic.

So, any idea in mind as in snippet section, was not able to find one!

Smoky Blue

QuoteAll I need "list of latest 15 topics" with URL leading to real topic but not to latest post on that topic.

that comes with tp automatic.. look in your block setting and set it up that way.. no need for a snippet or anything.. altho i have mine set to last 3 posts.. hope that helps ;)

Ricky.


Smoky Blue

didnt you just ask for the latest?? recent is close Ricky, but if you really want to get into a code for a mod to do the same thing, go for it  :D

bloc

You can use ssi..but you need to extract what you need and show only that. Normally a pre-defined layout is provided for ssi_recentTopics, but that can be changed. Something like..


global $settings, $scripturl, $context, $txt;

$what= ssi_recentTopics(8, NULL, 'array');

echo '
<table border="0" class="ssi_table">';
foreach ($what as $post)
echo '
<tr>
<td valign="top">
<a href="', $post['href'], '">', $post['subject'], '</a>
', $post['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt[302] . '" border="0" /></a>', '
</td>
</tr>';
echo '
</table>';




This only shows subject/link and if its new unread posts in it, no board and no author/time. Put it in a PHP block.

Zetan

QuoteWarning - while you were typing 2 new replies have been posted. You may wish to review your post.

pipped  :o

try this.. it's a custom snippet I made for myself.. you can see it on my home page.. the Review blocks.

I'm not a coder and I made this purely for myself.. if a coder can addapt it for all boards, thats fine.. but it's set for specific boards as is.



/******************************************************************************
* Reviews SSI                                                                 *
*******************************************************************************
* For TinyPortal                                                              *
*                                                                             *
* =========================================================================== *
* Software Version:           1.0                                             *
*                                                                             *
*                                                                             *
*                                                                             *
* Software by:                Zetan aka LAB DESIGN                            *
*                                                                             *
*                                                                             *
*          My First Code :D                                                   *
*             Damn being a n000b :P                                           *
*                                                                             *
*                                                                             *
*                                                                             *
* Support, News, Updates at:  This snippet is as. No updates guaranteed       *
*******************************************************************************
* This program is free software; you may redistribute it and/or modify it     *
* under the terms of the provided license as published by Lewis Media.        *
*                                                                             *
* This program is distributed in the hope that it is and will be useful,      *
* but WITHOUT ANY WARRANTIES; without even any implied warranty of            *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                        *
*                                                                             *
* See the "license.txt" file for details of the Simple Machines license.      *
* The latest version can always be found at http://www.simplemachines.org.    *
******************************************************************************/

// Review Type

{

echo '
<div style="padding: 5px;" class="mediumtext"><p style="margin: 0pt; padding: 0pt 0pt 0.5ex;"><img src="URL.com/review_ico.gif" align="absmiddle"></img>   
<a href="URL.com/board,66.0.html"  Title="Recent Member Gig Reviews from the Gig Reviews board.">Gig Reviews</a><br><hr width="100%" /></div>';


}       

// Fetch Board, Number of Topics Displayed. Subject, Time & Date and Topic Starter

$array = ssi_boardNews(66.0, 8, null, null, 'array');
foreach ($array as $r)   

{
echo '
<div style="padding: 0px;" class="smalltext"><p style="margin: 0pt; padding: 0pt 0pt 0.5ex;">
<a href="', $r['href'], '">', $r['subject'], '</a><br>',  '['.$r['time'].']', '<br>by <b>', $r['poster']['link'], '</b></p></div>';

if (!$r['is_last'])
echo '
<hr width="100%" />';
}

     
// Submit Review

{


echo '
<hr>
<div style="padding: 5px;" class="mediumtext"><p style="margin: 0pt; padding: 0pt 0pt 0.5ex;"><img src="http://URL.com/review_ico2.gif" align="absmiddle"></img>   
<a href="URL.com/index.php?action=post;board=66.0" Title="You must be a registered member to submit a review.">Submit a Review</a></div>';
}



It won't work straight away as I've removed my site URL details.. You'll need to change boards and other detail.

What it does is pull Topic, Author, Time and Date only.. No new posts, just Topic headings from a specific board. It can be changed to include all boards, but I'm posting it as is.

Ricky.

I guess, ssi_boardnews function can take only one board.. and I want topics to be displayed from whole FORUM.

Ricky.

Thnx bloc but I need "Latest Topics" and your code is deplaying recent topics.. ie. if someone replies to a old topic then it would come first. .. but I need latest topics only!

IchBin

What you're asking for is to ignore old topics? Thats a bit hard to do. By what criteria would you do this? How would you ignore old topics?  SMF displays the latest topic that is posted in. So how would you decide to display yours?

Smoky


Ricky.

Why we are having confusion over here ?

Let me explain again
....
When I use TP's built in Recent topic feature then it actually shows most recent replies to any of the post..

When I use RecentTopics feature of SSI then it actually shows  recent Topics started with most recent replies.

What Bloc posted here was showing recent replies but not the Latest Topics..

And what I want is simply list of "Latest Topics" started  on my board irrespective replies etc. Also it must lead to topic but not the latest reply on that topic.

You know I am digging many posts here and on smf forum just to find solution .. and now I certainly need to learn php properly.
Here is one such thread : its all about SSI http://www.simplemachines.org/community/index.php?topic=14906.0

Well, I understand that its confusing..

You go here and try to tell me what exactly the  is difference there in recenttopics and recentposts function ... bcz both are displaying almost same stuff........
http://www.simplemachines.org/community/ssi_examples.php


bloc

To clear things up..recent topics displays the title of the topic a recent post has been made in, with a "new" indicator to mark it, while recent posts displays the actual post(or subject of course). So the distinction is quite clear.

What you seek though, seems to be "latest created topics", and not "latest posts"? Regardless if it has new replies or not?

Ricky.

Yes..
I thought calling "Latest Topic" is enough .. but as Bloc made it clear. ..
I am referring to "Latest Topic Created" (irrespective replies to it) :)


jacortina

"Newest Topics" might be more appropriate:

global $scripturl, $settings, $db_prefix, $user_info, $modSettings;

$bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 4px 0 0;" />';

$list_count = 5;

$request = db_query("
SELECT
ms.subject AS firstSubject, ms.posterTime AS firstPosterTime, ms.ID_TOPIC, t.ID_BOARD, b.name AS bname
FROM ({$db_prefix}messages AS ms, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
WHERE   t.ID_TOPIC = ms.ID_TOPIC
AND b.ID_BOARD = t.ID_BOARD " . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? " AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
AND ms.ID_MSG = t.ID_FIRST_MSG
AND " . $user_info['query_see_board'] . "
ORDER BY t.ID_FIRST_MSG DESC LIMIT " . $list_count, __FILE__, __LINE__);

echo '
<table border="0">';

while ($row = mysql_fetch_assoc($request))
echo ' <tr>
<td valign="middle">', $bullet, '<a href="',  $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen"><b>', $row['firstSubject'], '</b></a></td>
</tr>';

echo '
</table border>';

bloc

Might be nice to add a time-limit on that. :) Especially if you add a relative high number. Otherwise you can still get old topics, just to fill up the counter.

jacortina

But, if the 10th 'newest' topic is a week old, a month old or a year old, it's still the 10th newest topic. Just means nobody has started many topics in all that time.

Of course, it's only the 10 newest topics that a user can SEE and excludes the recycle bin.

bloc

Yes, it is.

I don't know what the member here wants, but I would probably want to show just the newest..and a month old topic isn't "new" anymore. ;)

Ricky.

Quote from: J.A.Cortina on December 20, 2007, 04:44:25 PM
"Newest Topics" might be more appropriate:

global $scripturl, $settings, $db_prefix, $user_info, $modSettings;

$bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 4px 0 0;" />';

$list_count = 5;

$request = db_query("
SELECT
ms.subject AS firstSubject, ms.posterTime AS firstPosterTime, ms.ID_TOPIC, t.ID_BOARD, b.name AS bname
FROM ({$db_prefix}messages AS ms, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
WHERE   t.ID_TOPIC = ms.ID_TOPIC
AND b.ID_BOARD = t.ID_BOARD " . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? " AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
AND ms.ID_MSG = t.ID_FIRST_MSG
AND " . $user_info['query_see_board'] . "
ORDER BY t.ID_FIRST_MSG DESC LIMIT " . $list_count, __FILE__, __LINE__);

echo '
<table border="0">';

while ($row = mysql_fetch_assoc($request))
echo ' <tr>
<td valign="middle">', $bullet, '<a href="',  $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen"><b>', $row['firstSubject'], '</b></a></td>
</tr>';

echo '
</table border>';

This is what I need, thanx. Did little workaround and it worked.

Bloc, timelimit is good idea and can be used to show topics started in a particular span. Here member (that is me) just wanted Newest / Latest topic created irrespective of replies or time and that is what I got :)

Cheers!