TinyPortal

Development => Resources => Topic started by: janilxx on December 07, 2007, 06:03:46 PM

Title: Sort frontpage posts differently
Post by: janilxx on December 07, 2007, 06:03:46 PM
I show only forum posts from some categories in frontpage.

TPortal.php has this code

// Find the posts.
$request = db_query("
SELECT
m.icon, m.subject, m.body, IFNULL(mem.realName, m.posterName) AS posterName, m.posterTime,
t.numReplies, t.ID_TOPIC, m.ID_MEMBER, m.smileysEnabled, m.ID_MSG, t.locked, t.numViews,t.numReplies
FROM ({$db_prefix}topics AS t, {$db_prefix}messages AS m)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
WHERE t.ID_FIRST_MSG IN (" . implode(', ', $posts) . ")
AND m.ID_MSG = t.ID_FIRST_MSG
ORDER BY t.ID_FIRST_MSG DESC
LIMIT " . count($posts), __FILE__, __LINE__);


which I believe gets the posts from DB.


If I change order from
ORDER BY t.ID_FIRST_MSG DESC
to
t.ID_LAST_MSG
I suppose I would get topic ('s first message) on top on frontpage when someone adds new message to topic.


But I would like to get topic ('s first message) on top on frontpage when topic's first message is edited. So the order would be first by t.ID_FIRST_MSG DESC and then also by m.modifiedTime (which is 0 if message is not edited).

Would this be possible? And if yes, would someone give me code for this  :laugh:

Thanks.
Title: Re: Sort frontpage posts differently
Post by: bloc on December 08, 2007, 08:56:20 AM
Try to just add like: "ORDER BY t.ID_FIRST_MSG DESC,m.modifiedTime"

That would sort on ID_FIRST_MSG first, then modifiedTime.
Title: Re: Sort frontpage posts differently
Post by: cypher223 on February 11, 2008, 11:25:51 AM
it didn't work for me

I want to show the recent posts at the frontpage. The topics that comes in Recent post block should be displayed in the frontpage.

And is there any way to show posts from more than 5 boards. I can only select 5 boards to be shown in frontpage.
Title: Re: Sort frontpage posts differently
Post by: bloc on February 13, 2008, 08:34:14 AM
Recent posts..or recent topics? I am confused lol, the recent topics block show just topics, while frontpage "forumposts" show only posts from 5 selected boards.

To show recent topics on frontpage too, just use a frontpage block with type "recent topics". As for more than 5 boards, no, not without modifying 4 files in the process.
Title: Re: Sort frontpage posts differently
Post by: cypher223 on February 14, 2008, 08:55:32 AM
I mean to say that . Front page should show the recent updated topic not the topic that was started first. And in frontpage we can see only the first post of the topic but i want to show off the latest post or the last post.

for eg- I have a topic which shows the results of the premierleague so whenever i reply in this topic with the new scores, this topic should be shown in the frontpage with the latest scores.

I have solved the problem of showing the latest updated topic by changing

ORDER BY FIRST_MSG_ID DESC 
to
ORDER BY LAST_MSG_ID DESC


but i cant show the latest post of the topic in the frontpage.
Title: Re: Sort frontpage posts differently
Post by: cypher223 on February 14, 2008, 08:59:56 AM
and about showing more than 5 boards.

If it is not possible to show from more than 5 boards. Is is possible to randomly select the 5 board from which the topic will be shown. Some times from sports board and somtimes from Music board.
Title: Re: Sort frontpage posts differently
Post by: IchBin on February 14, 2008, 04:55:22 PM
To choose more boards for board news on frontpage.
http://www.tinyportals.net/index.php?topic=13069.msg125356#msg125356

Did you try recentPosts for your frontpage instead of boardnews?
Title: Re: Sort frontpage posts differently
Post by: cypher223 on February 19, 2008, 09:43:43 AM
Where can i choose recent post. There are options like

Only forum posts
Forum posts and articles etc...

And i have choosen only Forum post
Title: Re: Sort frontpage posts differently
Post by: IchBin on February 19, 2008, 02:26:43 PM
If you want recent posts you need to put them in a block or article. Check the block code snippets board for the code to get what you want.
Title: Re: Sort frontpage posts differently
Post by: cypher223 on February 23, 2008, 08:27:43 AM
I could not find anything helpful.

When we click on the "view most recent posts on the Forum" we can see the latest post of the forum.

Can u prepare a code to place in a block which will show the same results.

The recent post page shows the complete post but i need to show only a part of the post if its long. Reply soon i am online now in my msn

pravin_threedee@hotmail.com
Title: Re: Sort frontpage posts differently
Post by: cypher223 on February 23, 2008, 09:42:54 AM
Well u don't have to worry anymore IchBin. I have fixed it myself. If anyone need this. The code edits are given below.

Open $boarddir/Sources/TPortal.php

Search for


// Find the post ids.
$request = db_query("
SELECT t.ID_FIRST_MSG
FROM ({$db_prefix}topics as t, {$db_prefix}boards as b)
WHERE t.ID_BOARD IN (". $board .")
AND t.ID_BOARD=b.ID_BOARD
AND $user_info[query_see_board]
ORDER BY t.ID_FIRST_MSG DESC
LIMIT $start, $limit", __FILE__, __LINE__);
$posts = array();
while ($row = mysql_fetch_assoc($request))
$posts[] = $row['ID_FIRST_MSG'];
mysql_free_result($request);

if (empty($posts))
return array();

// Find the posts.
$request = db_query("
SELECT
m.icon, m.subject, m.body, IFNULL(mem.realName, m.posterName) AS posterName, m.posterTime,
t.numReplies, t.ID_TOPIC, m.ID_MEMBER, m.smileysEnabled, m.ID_MSG, t.locked, t.numViews,t.numReplies
FROM ({$db_prefix}topics AS t, {$db_prefix}messages AS m)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
WHERE t.ID_FIRST_MSG IN (" . implode(', ', $posts) . ")
AND m.ID_MSG = t.ID_FIRST_MSG
ORDER BY t.ID_FIRST_MSG DESC
LIMIT " . count($posts), __FILE__, __LINE__);



And Replace with this


// Find the post ids.
$request = db_query("
SELECT t.ID_LAST_MSG
FROM ({$db_prefix}topics as t, {$db_prefix}boards as b)
WHERE t.ID_BOARD IN (". $board .")
AND t.ID_BOARD=b.ID_BOARD
AND $user_info[query_see_board]
ORDER BY t.ID_LAST_MSG DESC
LIMIT $start, $limit", __FILE__, __LINE__);
$posts = array();
while ($row = mysql_fetch_assoc($request))
$posts[] = $row['ID_LAST_MSG'];
mysql_free_result($request);

if (empty($posts))
return array();

// Find the posts.
$request = db_query("
SELECT
m.icon, m.subject, m.body, IFNULL(mem.realName, m.posterName) AS posterName, m.posterTime,
t.numReplies, t.ID_TOPIC, m.ID_MEMBER, m.smileysEnabled, m.ID_MSG, t.locked, t.numViews,t.numReplies
FROM ({$db_prefix}topics AS t, {$db_prefix}messages AS m)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
WHERE t.ID_LAST_MSG IN (" . implode(', ', $posts) . ")
AND m.ID_MSG = t.ID_LAST_MSG
ORDER BY t.ID_LAST_MSG DESC
LIMIT " . count($posts), __FILE__, __LINE__);


Using this u can get the latest post of your Forum.