Best of joomla gives you news, joomla templates, tutorials and websites about Joomla , FireBoard and FireMessage official page.
| No account yet?   |
Welcome, Guest
Please Login or Register.    Lost Password?
Last X posts from latest threads (hack) (1 viewing) (1) Guest
Go to bottom Favoured: 0
TOPIC: Last X posts from latest threads (hack)
#51951
Last X posts from latest threads (hack) 2 Months, 2 Weeks ago  
I needed a way to show the last X posts from the latest threads and I couldn't find any existing extension that does it for FB 1.0.4 and J! 1.5.3
So I decided to hack the fb latest posts module in order to do just that.

Steps involved:
1. cleanup/create table
Code:


drop procedure get_latest_thread_post;
drop table if exists jos_fb_latest_thread_post;
create table jos_fb_latest_thread_post select id, catid, name, userid, subject, time, topic_emoticon from jos_fb_messages where 1=0;



2. create stored procedure

Code:


create procedure get_latest_thread_post()
begin
    DECLARE done INT DEFAULT 0;
    DECLARE threadv int;

    DECLARE latest_threads CURSOR FOR select thread from jos_fb_messages where parent=0 order by time desc limit 20;
    DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;

    OPEN latest_threads;

    /* initialise */
    truncate table jos_fb_latest_thread_post;
    FETCH latest_threads INTO threadv;
    REPEAT
        insert into jos_fb_latest_thread_post (id, catid, name, userid, subject, time, topic_emoticon)
        select id, catid, name, userid, subject, time, topic_emoticon from jos_fb_messages
        where thread = threadv
        order by time desc
        limit 1;
        FETCH latest_threads INTO threadv;
    UNTIL done END REPEAT;

    CLOSE latest_threads;
end



3. modify helper.php - backup first- just after the comment "// Get latest post from the DBase"

Code:


        // Get latest post from the DBase

//ORIGINAL $query = ' SELECT id, catid,name, userid, subject, time, topic_emoticon FROM #__fb_messages ORDER BY time DESC LIMIT '.$postings.'';
        //ORIGINAL $database -> setQuery( $query );
        //ORIGINAL $rows = $database -> loadObjectList();

       // call stored procedure which populates the table with the last 20 posts of latest threads
        $query = 'call get_latest_thread_post';
        $database -> setQuery( $query );
        $database->query();
        
        //$rows = $database -> loadObjectList();
        $query = 'select id, catid, name, userid, subject, time, topic_emoticon from #__fb_latest_thread_post order by time desc limit '.$postings.'';
        $database -> setQuery( $query );
        $rows = $database -> loadObjectList();

mijalis (User)
Fresh Boarder
Posts: 4
graphgraph
User Offline Click here to see the profile of this user
Logged Logged
 
Last Edit: 2008/06/13 21:35 By mijalis.
 
The administrator has disabled public write access.  
Go to top
Powered by FireBoard - Creditsget the latest posts directly to your desktop