Show Top 5 Stories with URL on any page

Register an Account
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 02-04-2007, 05:38 AM
Casual Pligger
 
Join Date: Feb 2007
Posts: 70
Hello,
Thanks to some of the forum gods, I figured this out and am using this now.

To show 5 (you can select any number) of the top rated stories in an un-numbered list.

Add this to html1.php:
PHP Code:
    //this is for the top 5 stories list. change LIMIT 0,5 to the number u want
    
$storytopSql "SELECT link_id, link_title, link_title_url from " table_links " where link_status = 'published' or link_status = 'queued' ORDER BY link_votes DESC LIMIT 0,5;";
    
$stories1 $db->get_results($storytopSql);
    
//store the id and title in an array
    
$storytoplist = array();
    foreach ( 
$stories1 as $storytop )
        
$storytoplist[] = array($storytop->link_id,$storytop->link_title,$storytop->link_title_url);
    
//pass the array to the template
    
$var_smarty->assign('topStories',$storytoplist); 
Add this to the template page/section you want:
PHP Code:
                        <ul>
                            {foreach 
from=$topStories value=topstory}
                            <
li> <a href="http://yoursite.com/story.php?title={$topstory[2]}">{$topstory[1]}</a></li>
                            {/foreach}
                        </
ul

Last edited by kanedaguy; 02-04-2007 at 07:11 AM.
Reply With Quote
  #2 (permalink)  
Old 02-04-2007, 01:05 PM
pogung177's Avatar
Casual Pligger
 
Join Date: Dec 2006
Posts: 34
Great tips, i'll try modif display 5 stories in same categories
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Page Variables Yankidank Wiki Articles 3 05-19-2011 09:21 AM
Show Stories Differently on the Front Page and the Category Page maxkiesler Questions and Comments 3 02-28-2010 01:49 AM
how to show more stories in home page? blueonline Questions and Comments 3 01-21-2008 11:25 PM
Show Page Thumbnails on main page seer Questions and Comments 2 11-20-2007 05:20 AM
Show voted on stories on profile page revolver Questions and Comments 5 12-13-2006 01:56 AM


Pligg Modules and Pligg Templates from Pligg Pro Find support on the Pligg CMS Forum - 24 hours a day! Make a donation to support Pligg CMS development