Firefox PHP

e107

Posted by quiznos 
e107
November 24, 2008 07:38AM
I want to put the latest posts on my e107 front page.
How is this possible?
Zack
Re: e107
November 24, 2008 07:47AM
Use an RSS script to read the Phorum RSS feed and let that present the latest posts on your front page.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: e107
November 24, 2008 07:54AM
$sql = "select phorum_messages.* from phorum_messages, phorum_forums
WHERE phorum_messages.forum_id = phorum_forums.forum_id and phorum_forums.pub_perms>0 and phorum_messages.status=2 and phorum_messages.moved=0 ORDER BY phorum_messages.datestamp desc limit $num";

This will also pick up the latest num posts from the forum.
Re: e107
November 25, 2008 03:23AM
I use the following code to get latest 6 post in the bottom of my forum (http://www.u2eastlink.com/phorun/list.php?5)
However, it always shows latest updated messages for the complete forum, while I only want the updated ones from that specific forum. What should I change in the phorum_db_get_recent_messages string (forum id) to get those I want?

Second question. Is this the most optimal way (speed, performance, clean code) to do this?

Thanks :)

Language: PHP
<?       $msgs = phorum_db_get_recent_messages(6,0,$forum_id,0,LIST_RECENT_MESSAGES); foreach ($msgs as $onemsg) { if ($onemsg[';subject';]) { $datestamp = $onemsg[';modifystamp';] ? $onemsg[';modifystamp';] : $onemsg[';datestamp';] ; echo "<tr><td><a href=\"read.php?".$onemsg[';forum_id';].",".$onemsg[';thread';].",".$onemsg[';message_id';]."#msg-".$onemsg[';message_id';]."\">".$onemsg[';subject';]."</a></td><td>".$onemsg[';author';]."</td><td>".date(" d M H:m",$onemsg[';datestamp';])."</td></tr>"; } }   ?>



Edited 1 time(s). Last edit at 11/25/2008 03:25AM by Diego.
Re: e107
November 25, 2008 03:32AM
did you check that $forum_id is set there at all? I really doubt that.


Thomas Seifert
Re: e107
November 25, 2008 04:11AM
Change LIST_RECENT_MESSAGES to LIST_UPDATED_THREADS. Sounds like that is what you're looking for.

Note that you are introducing an XSS security leak here. Never print code directly to the browser without formatting it first or without knowing for sure that this is not required. If people now enter some <script> code in their message subjects, it will execute in the browser when looking at your list. At least put an htmlspecialchars() call around the fields that contain user input (in this case "subject" and "author").


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: e107
November 25, 2008 11:39PM
Changing to LIST_RECENT_MESSAGES makes no difference. Basically i still get the messages but from the whole phorum.

I guess this is not the optimal to do it. I am not a coder so I do everything as I can
This time I did a shameless copy past from my old script from Phorum 3.
So far I can get the array via phorum_db_get_recent_messages

My questions are:

1. What should I use instead of $forum_id? Syntax is clear but I don't know the variable I should use here (is there a list of global variables? couldnt find it on the docs

2. Once I have the $msg captured, what would be optimal way to do it? I used simply (and dangerous) PHP code to show it but I know this could be much more efficient. What should I use here?

Thanks
Re: e107
November 26, 2008 12:15AM
Quote
Diego
My questions are:

1. What should I use instead of $forum_id? Syntax is clear but I don't know the variable I should use here (is there a list of global variables? couldnt find it on the docs
It looks like you are only adding this to the list pages, so you can use $PHORUM["forum_id"] after calling global $PHORUM;

Quote

2. Once I have the $msg captured, what would be optimal way to do it? I used simply (and dangerous) PHP code to show it but I know this could be much more efficient. What should I use here?

I would suggest using a modified version of the code from earlier in the list.tpl where the messages are listed in the main section of the page and also looking at the relevant code in list.php for creating the variables (especially the read url).


Joe Curia (aka Azumandias)
Modules: l0Admin Mass Email00000000l000000Automatic Time Zones000ll.l00000Enhanced Custom Profiles0.00Google Calendar0000l.l000000Post Previews
000000000Admin Security Suite000000000000Check Modules for Upgrades0000External Authentication000000Group Auto-Email00000.00000Private Message Alerts
000000000Attachment Download Counter0000Custom Attachment Icons000ll.ll00Favorite Forums000000.00000Highlighted Search Terms0000Self-Delete Posts Option
000000000Attachment Watermarks0l00000000Custom Language Database00l.l.0Forum Lockdown00000.00000Ignore Forums0000000000000Threaded Tree View
000000000Automatic Message Pruning00.llll.00Easy Color Scheme Manager0l.l00Forum Subscriptions0000lll000Moderated User Group
Templates:lGeneric Integration000000000 0000Simple Rounded000000 00000000Tabbed Emerald
Re: e107
November 26, 2008 12:45PM
Quote
quiznos
I want to put the latest posts on my e107 front page.
How is this possible?

I don't know what e107 is or does it even matter

[www.phorum.org]
[www.phorum.org]
[www.phorum.org]

---
-=[ Panu ]=-
Re: e107
December 07, 2008 04:11AM
Yeah I pointed wrong thread but Joe's post was EXACTLY what I was looking for.


Language: PHP
<?php global $PHORUM; $msgs = phorum_db_get_recent_messages(6,0,$PHORUM["DATA"]["FORUM_ID"],0,LIST_RECENT_MESSAGES); $PHORUM["DATA"]["ULTIMOS"] = $msgs; ?>   <table> <tr> <th>Last messages</th> </tr>   {LOOP ULTIMOS} <tr><td>{ULTIMOS->subject}</td><td>{ULTIMOS->author}</td><td>{ULTIMOS->datestamp}</td></tr> {/LOOP ULTIMOS} </table>


Really clean way to show what I wanted.
Just two additional questions

The generated array is sort of limited field selection compared to normal listing. Normal list arrays have an useful subarray URL. I know I could generate via PHP full URL (base phorum url + read.php + [phorum id] + [thread]).
Is there a "cleaner" way to show full message URL, either in the same way is done in normal templates (MESSAGES->URL->PROFILE) or any other Phorum function.

Same with date, I got datestamp wich is the raw date, what is the actual function I should use to do proper date formatting?

Thanks again, big help :)



Edited 1 time(s). Last edit at 12/07/2008 04:14AM by Diego.
Sorry, only registered users may post in this forum.

Click here to login