Display User's Saved Stories in Sidebar

Register an Account
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 11-12-2007, 01:17 AM
Casual Pligger
 
Join Date: Jan 2007
Posts: 46
I want my users to see their saved stories in the sidebar... I think I've almost got it.

Here's the .php file so far, it will show all the recently saved stories for all users. I want to limit this to show only the saved stories for the user who is logged in.

Create a file called sidebar_saved.php in your root or where the other .php files are all stored.

PHP Code:
<?php
// The source code packaged with this file is Free Software, Copyright (C) 2005 by
// Ricardo Galli <gallir at uib dot es>.
// It's licensed under the AFFERO GENERAL PUBLIC LICENSE unless stated otherwise.
// You can get copies of the licenses here:
//         http://www.affero.org/oagpl.html
// AFFERO GENERAL PUBLIC LICENSE is also included in the file called "COPYING".
// -------------------------------------------------------------------------------------

include_once('Smarty.class.php');
$main_smarty = new Smarty;

include_once(
'config.php');
include_once(
mnminclude.'html1.php');
include_once(
mnminclude.'link.php');
include_once(
mnminclude.'tags.php');
include_once(
mnminclude.'search.php');
include_once(
mnminclude.'smartyvariables.php');

// -------------------------------------------------------------------------------------

global $the_template$main_smarty$db;

echo 
"<div class=\"tlb\"><span><a onclick=\"new Effect.toggle('savedlinks','blind', {queue: 'end'}); \">  +/-</a></span></div>Recently Saved<div id=\"savedlinks\">";

$res "select link_id,link_title,saved_id,saved_user_id,saved_link_id from ".table_links.",".table_saved_links." WHERE saved_link_id = link_id ORDER BY saved_id DESC limit 20";
$list_savedlinks $db->get_results($res);
if(
$list_savedlinks)
{
    foreach(
$list_savedlinks as $row){            
        
$story_url getmyurl("story"$row->link_id);
        echo 
"<a class='switchurl' href='".$story_url."'>".$row->link_title."</a>";                
    }
}

echo 
"</div>";
    
    
?>
To add it to the sidebar create a file called sidebar_saved.tpl with these contents and place it in your sidebar modules folder.

PHP Code:
{* ----- show the sidebar stories box ----- *}
    {
php}include('sidebar_saved.php');{/php}
{* ---------------------------------------- *} 
Finally, add this code to your sidebar.tpl

PHP Code:
{assign var=sidebar_module value="sidebar_saved"}{include file=$the_template_sidebar_modules."/wrapper.tpl"
This will put recently saved stories by all users in the sidebar, but I need help limiting the result to just the user's own saved stories.
Reply With Quote
  #2 (permalink)  
Old 05-17-2008, 06:08 AM
longcountdown's Avatar
Pligg Donor
Pligg Version: 9.8.2
Pligg Template: moderno-orange
 
Join Date: Nov 2007
Location: Japan
Posts: 75
I can't answer your question about limiting it to the current user, but thanks very much for this code. It's just what I was looking for.
Reply With Quote
  #3 (permalink)  
Old 05-17-2008, 07:23 AM
Casual Pligger
 
Join Date: Feb 2008
Posts: 33
Ok. It works But I add some improvements to that:

1)I deleted that from sidebar_saved.php

Code:
echo "<div class=\"tlb\"><span><a onclick=\"new Effect.toggle('savedlinks','blind', {queue: 'end'}); \">  +/-</a></span></div>Recently Saved<div id=\"savedlinks\">"; 

echo "</div>";
2) I open sidebar_saved.tpl and on the beginning add:

Code:
<div class="tlb">
	<span><a onclick="new Effect.toggle('user_data','blind', {ldelim}queue: 'end'{rdelim});"> <img src="{$my_pligg_base}/templates/{$the_template}/images/expand.png" alt="expand" /></a></span>

	<a href="#">Recently saved news</a>
</div>
3)Finally i change the code in sidebar.tpl. Now users who are not registered see nothing because the don't need that panel

Code:
{if $user_authenticated eq true}
{assign var=sidebar_module value="sidebar_saved"}{include file=$the_template_sidebar_modules."/wrapper.tpl"}
{/if}
Reply With Quote
  #4 (permalink)  
Old 06-08-2010, 02:19 PM
New Pligger
Pligg Version: 1.0.4.
Pligg Template: Interface
 
Join Date: May 2010
Location: Canada
Posts: 17
Excellent stuff!
Only issue I have is that I have some news twice...any idea why?
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
iFrame with vote and sidebar published stories nzbullet Questions and Comments 25 09-15-2009 08:00 PM
Stories submitted by users that are not listed in Admin Users list... (RC2) Tomek Wlodarek Questions and Comments 0 02-25-2009 04:41 AM
Saved Stories crosses users javin666 Questions and Comments 4 02-16-2009 04:15 PM
New Mod -- Display related stories revenazb Questions and Comments 46 07-07-2007 02:19 AM
Pligg beta 9.5 [updated] kbeeveer46 Current Version 0 04-29-2007 10:58 PM


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