Contentteller

Contentteller Support Forums
Home Forums > Customizing Contentteller > Modules and Blocks >

Latest forum posts block

Discussion in 'Modules and Blocks' started by error, Sep 17, 2008.

  1. error Customer

    Latest forum posts block

    I would like to see Latest 10 forum posts in a block. Similar to Latest News. Also with choice too limit text length.

    Thanks
    error, Sep 17, 2008
    #1
  2. Philipp Administrator

    Create a new blocks/ipb_latest.php file with the following content:

    PHP:
    <?php

    if( !defined( "CONTENTTELLER" ) )
    {
        die( 
    "Error" );
    }

    $ipb_latest = ( isset( $datastore[ 'ipb_latest' ] ) ) ? $datastore[ 'ipb_latest' ] : "" ;

    if( !
    $ipb_latest )
    {
        global 
    $uwrapper;
        
        
    $ipb_latest = "";        
        
    $uwrapper -> bbconnect();    
        
        
    $results = $uwrapper -> bbquery( "SELECT tid, title, forum_id FROM " . $uwrapper -> bbescape( $preferences[ 'website_uwrapper_prefix' ] ) . "topics ORDER BY last_post DESC LIMIT 10" );
        if( 
    $uwrapper -> bbrows( $results ) )
        {
            while( list( 
    $threadid, $title, $forum ) = $database -> dbrow( $results ) )
            {
                
    $length = 22; 
                if ( 
    strlen( $title ) > $length) 
                { 
                    
    $title = substr ( $title, 0, $length ) . "..."; 
                }  
                
    $ipb_latest .= "&middot; <a href=\"" . $preferences['website_uwrapper_forumpath'] . "/index.php?act=ST&amp;f=" . $forum . "&amp;t=" . $threadid . "\">" . htmlspecialchars( $title ) . "</a><br />";
                
            }
        }
        
    $uwrapper -> bbclose();
        
    $system -> datastoreput( "ipb_latest", $ipb_latest );
    }
        
    echo 
    $ipb_latest;

    ?>
    You may need to adjust this SQL query to exclude private forums:

    PHP:
    $results = $uwrapper -> bbquery( "SELECT tid, title, forum_id FROM " . $uwrapper -> bbescape( $preferences[ 'website_uwrapper_prefix' ] ) . "topics ORDER BY last_post DESC LIMIT 10" );
    For example, if you like to exclude forum 10 and 15 from the list just change the query to:

    PHP:
    $results = $uwrapper -> bbquery( "SELECT tid, title, forum_id FROM " . $uwrapper -> bbescape( $preferences[ 'website_uwrapper_prefix' ] ) . "topics WHERE NOT(forum_id = '10') AND NOT(forum_id = '15') ORDER BY last_post DESC LIMIT 10" );
    Philipp, Sep 17, 2008
    #2
  3. error Customer

    It works well. I get only one issue.

    can't restart Windows from DOS

    instead of

    can't restart Windows from DOS

    What can be problem?
    error, Sep 18, 2008
    #3
  4. Philipp Administrator

    error;251 said:
    can't restart Windows from DOS

    instead of

    can't restart Windows from DOS
    I don't see a difference :confused:
    Philipp, Sep 18, 2008
    #4
  5. error Customer

    can& # 3 9 ;t restart Windows from DOS
    You see now?

    It shows & # 3 9 ;

    instead of '
    error, Sep 18, 2008
    #5
  6. Philipp Administrator

    This following should work. Change:

    PHP:
                $ipb_latest .= "&middot; <a href=\"" . $preferences['website_uwrapper_forumpath'] . "/index.php?act=ST&amp;f=" . $forum . "&amp;t=" . $threadid . "\">" . htmlspecialchars( $title ) . "</a><br />";
    to:

    PHP:
                $ipb_latest .= "&middot; <a href=\"" . $preferences['website_uwrapper_forumpath'] . "/index.php?act=ST&amp;f=" . $forum . "&amp;t=" . $threadid . "\">" . $title . "</a><br />";
    Philipp, Sep 18, 2008
    #6
  7. Ryster New Member

    Hi there, could you possibly whip up a similar block for phpbb3 recent articles too please? IPB was nice until they made you start paying for it. I don't want to pay just for a clan website with 30 members.
    Ryster, Nov 1, 2008
    #7
  8. Philipp Administrator

    This should work for phpBB 3:

    PHP:
    <?php 

    if( !defined( "CONTENTTELLER" ) ) 
    { 
        die( 
    "Error" ); 
    } 

    $pbb_latest = ( isset( $datastore[ 'pbb_latest' ] ) ) ? $datastore[ 'pbb_latest' ] : "" ; 

    if( !
    $pbb_latest ) 
    { 
        global 
    $uwrapper; 
         
        
    $pbb_latest = "";         
        
    $uwrapper -> bbconnect();     
         
        
    $results = $uwrapper -> bbquery( "SELECT topic_id, topic_title, forum_id FROM " . $uwrapper -> bbescape( $preferences[ 'website_uwrapper_prefix' ] ) . "topics WHERE topic_approved = '1' ORDER BY topic_last_post_time DESC LIMIT 10" ); 
        if( 
    $uwrapper -> bbrows( $results ) ) 
        { 
            while( list( 
    $threadid, $title, $forum ) = $database -> dbrow( $results ) ) 
            { 
                
    $length = 22;  
                if ( 
    strlen( $title ) > $length)  
                {  
                    
    $title = substr ( $title, 0, $length ) . "...";  
                }   
                
    $pbb_latest .= "&middot; <a href=\"" . $preferences['website_uwrapper_forumpath'] . "/viewtopic.php?f=" . $forum . "&amp;t=" . $threadid . "\">" . htmlspecialchars( $title ) . "</a><br />"; 
                 
            } 
        } 
        
    $uwrapper -> bbclose(); 
        
    $system -> datastoreput( "pbb_latest", $pbb_latest ); 
    } 
         
    echo 
    $pbb_latest; 

    ?>
    Philipp, Nov 1, 2008
    #8
  9. DSF2 New Member

    There is is a block available for SMF ?

    Thank You,
    DSF2, Oct 6, 2009
    #9
  10. Forma Customer

    for the one for phpbb, could it also display the time of the last post, and who made it, and also the post count?

    You made one before for storyteller like this :)
    Forma, Dec 23, 2009
    #10
  11. Philipp Administrator

    Forma;1397 said:
    for the one for phpbb, could it also display the time of the last post, and who made it, and also the post count?
    This should work:

    PHP:
        $results = $uwrapper -> bbquery( "SELECT topic_id, topic_title, forum_id, topic_last_post_time, topic_last_poster_name, topic_replies FROM " . $uwrapper -> bbescape( $preferences[ 'website_uwrapper_prefix' ] ) . "topics WHERE topic_approved = '1' ORDER BY topic_last_post_time DESC LIMIT 10" ); 
        if( 
    $uwrapper -> bbrows( $results ) ) 
        { 
            while( list( 
    $threadid, $title, $forum, $topic_last_post_time, $topic_last_poster_name, $topic_replies ) = $database -> dbrow( $results ) ) 
            { 
                
    $length = 22;  
                if ( 
    strlen( $title ) > $length)  
                {  
                    
    $title = substr ( $title, 0, $length ) . "...";  
                }   
                
    $pbb_latest .= "&middot; <a href=\"" . $preferences['website_uwrapper_forumpath'] . "/viewtopic.php?f=" . $forum . "&amp;t=" . $threadid . "\">" . htmlspecialchars( $title ) . "</a> (" . htmlspecialchars( $topic_replies ) ." replies)<br />Posted by " . htmlspecialchars( $topic_last_poster_name) . " on: " . date("m/d/y H:i:s",  $topic_last_post_time); 
                 
            } 
        } 
    Philipp, Dec 23, 2009
    #11
  12. error Customer

    After upgrade to IPB 3.0.5 ipb latest doesn't work. Here is a code:

    Code:
    <?php 
    
    if( !defined( "CONTENTTELLER" ) ) 
    { 
        die( "Error" ); 
    } 
    
    $ipb_latest = ( isset( $datastore[ 'ipb_latest' ] ) ) ? $datastore[ 'ipb_latest' ] : "" ; 
    
    if( !$ipb_latest ) 
    { 
        global $uwrapper; 
         
        $ipb_latest = "";         
        $uwrapper -> bbconnect();     
         
        $results = $uwrapper -> bbquery( "SELECT tid, title, forum_id FROM " . $uwrapper -> bbescape( $preferences[ 'website_uwrapper_prefix' ] ) . "topics WHERE NOT(forum_id = '83') AND NOT (forum_id = '51') AND NOT (forum_id = '79') ORDER BY last_post DESC LIMIT 5" ); 
        if( $uwrapper -> bbrows( $results ) ) 
        { 
            while( list( $threadid, $title, $forum ) = $database -> dbrow( $results ) ) 
            { 
                $length = 23;  
                if ( strlen( $title ) > $length)  
                {  
                    $title = substr ( $title, 0, $length ) . "...";  
                }   
              $ipb_latest .= "<li><a href=\"" . $preferences['website_uwrapper_forumpath'] . "/index.php?act=ST&amp;f=" . $forum . "&amp;t=" . $threadid . "\">" . $title . "</a></li>";  
    
    
                 
            } 
        } 
        $uwrapper -> bbclose(); 
        $system -> datastoreput( "ipb_latest", $ipb_latest ); 
    } 
         
    echo $ipb_latest; 
    
    ?> 
    
    error, Feb 18, 2010
    #12
  13. Philipp Administrator

    The following modification should work for IPB 3.0.5:

    PHP:
        $results = $uwrapper -> bbquery( "SELECT tid, title, forum_id, title_seo FROM " . $uwrapper -> bbescape( $preferences[ 'website_uwrapper_prefix' ] ) . "topics WHERE NOT(forum_id = '83') AND NOT (forum_id = '51') AND NOT (forum_id = '79') ORDER BY last_post DESC LIMIT 5" ); 
        if( 
    $uwrapper -> bbrows( $results ) ) 
        { 
            while( list( 
    $threadid, $title, $forum, $title_seo ) = $database -> dbrow( $results ) ) 
            { 
                
    $length = 23;  
                if ( 
    strlen( $title ) > $length)  
                {  
                    
    $title = substr ( $title, 0, $length ) . "...";  
                }   
                
    $ipb_latest .= "<li><a href=\"" . $preferences['website_uwrapper_forumpath'] . "/topic/" . $threadid . "-" . $title_seo . "\">" . $title . "</a></li>";             
            } 
        } 
    Philipp, Feb 18, 2010
    #13
  14. error Customer

    It works but not goes to last post instead goes to first post in topic. Thanks.
    error, Feb 18, 2010
    #14
  15. Philipp Administrator

    This should work:

    PHP:
    $ipb_latest .= "<li><a href=\"" . $preferences['website_uwrapper_forumpath'] . "/topic/" . $threadid . "-" . $title_seo . "/page__view__getnewpost\">" . $title . "</a></li>";
    Philipp, Feb 18, 2010
    #15
  16. error Customer

    Thanks. This one works. Now I only need to fix this cookie issue with CT.

    http://community.contentteller.com/f6/338_cookies_issue,4.html
    error, Feb 18, 2010
    #16
  17. error Customer

    IPB 3.1.3 - Latest Forum Posts doesn't work after upgrade.

    Code:
    <?php 
    
    if( !defined( "CONTENTTELLER" ) ) 
    { 
        die( "Error" ); 
    } 
    
    $ipb_latest = ( isset( $datastore[ 'ipb_latest' ] ) ) ? $datastore[ 'ipb_latest' ] : "" ; 
    
    if( !$ipb_latest ) 
    { 
        global $uwrapper; 
         
        $ipb_latest = "";         
        $uwrapper -> bbconnect();     
         
       $results = $uwrapper -> bbquery( "SELECT tid, title, forum_id, title_seo FROM " . $uwrapper -> bbescape( $preferences[ 'website_uwrapper_prefix' ] ) . "topics WHERE NOT(forum_id = '83') AND NOT (forum_id = '51') AND NOT (forum_id = '79') ORDER BY last_post DESC LIMIT 5" );  
        if( $uwrapper -> bbrows( $results ) )  
        {  
            while( list( $threadid, $title, $forum, $title_seo ) = $database -> dbrow( $results ) )  
            {  
                $length = 23;   
                if ( strlen( $title ) > $length)   
                {   
                    $title = substr ( $title, 0, $length ) . "...";   
                }    
               $ipb_latest .= "<li><a href=\"" . $preferences['website_uwrapper_forumpath'] . "/topic/" . $threadid . "-" . $title_seo . "/page__view__getnewpost\">" . $title . "</a></li>";  
    
                
            }  
        }  
    
    
        $uwrapper -> bbclose(); 
        $system -> datastoreput( "ipb_latest", $ipb_latest ); 
    } 
         
    echo $ipb_latest; 
    
    ?> 
    
    error, Nov 11, 2010
    #17
  18. Philipp Administrator

    You need to remove the / after board from your forum path (e.g. yourdomain.tld/board/ to yourdomain.tld/board)
    Philipp, Nov 11, 2010
    #18
Tweet
Facebook:
Forgot your password?
Contentteller Support Forums
Home Forums > Customizing Contentteller > Modules and Blocks >
  • Home
  • Forums

    Forums

    Quick Links
    • Search Forums
    • What's New?
  • Members

    Members

    Quick Links
    • Registered Members
    • Current Visitors
    • Recent Activity
  • Help

    Help

    Quick Links
    • Smilies
    • BB Codes
    • Trophies

Separate names with a comma.

Advanced search...
    Forum software by XenForo™ ©2011 XenForo Ltd.