1. First thing you need to do, login to PHPmyAdmin and create a table with the title "pligg_stories" or anything else you would like. I recommend just doing this by hand instead of using the query code. It is very easy to figure out, considering I knew NOTHING about php or sql before attempting this. Within the table, create 3 rows.
1st row: FIELD: stories_id, TYPE: INT(20), EXTRA: auto_increment
2nd row: FIELD: user_id, TYPE: INT(20), DEFAULT: 0
3rd row: FIELD: link_id, TYPE: INT(20), DEFAULT: 0
2. You will need 2 new files in your main directory, addstories.php and remstories.php. The code for them follows or you can just DOWNLOAD the attached files which are identical.
addstories.php:
Code:
<?php
include_once('Smarty.class.php');
$main_smarty = new Smarty;
include('config.php');
include(mnminclude.'html1.php');
include(mnminclude.'link.php');
include(mnminclude.'smartyvariables.php');
// "Save this" feature by Nick Strand, http://strandalo.us
// -------------------------------------------------------------------------------------
if($current_user->user_id != 0)
{
global $db, $the_template;
$linkid = $_REQUEST['category'];
$link = new Link;
$link->id=$linkid;
$link->read();
$title = $db->get_var("SELECT link_title_url FROM " . table_links . " WHERE link_id = $linkid");
if (!$db->get_row("SELECT stories_id, user_id, link_id FROM " . table_stories . " WHERE link_id = $linkid AND user_id = $current_user->user_id"))
{
$sql="INSERT INTO " . table_stories . " (user_id, link_id) VALUES ($current_user->user_id, $linkid)";
$db->query($sql);
}
if($_REQUEST['from'] == 1)
{
//header ('Location: http://strandalo.us/story.php?title='.$title);
header ('Location: http://strandalo.us/user.php?login='.$current_user->user_login.'&view=stories');
}
}
?> Code:
<?php
include_once('Smarty.class.php');
$main_smarty = new Smarty;
include('config.php');
include(mnminclude.'html1.php');
include(mnminclude.'link.php');
include(mnminclude.'smartyvariables.php');
// "Save this" feature by Nick Strand, http://strandalo.us
// -------------------------------------------------------------------------------------
if($current_user->user_id != 0)
{
global $db, $the_template;
$linkid = $_REQUEST['category'];
$link = new Link;
$link->id=$linkid;
$link->read();
$title = $db->get_var("SELECT link_title_url FROM " . table_links . " WHERE link_id = $linkid");
if ($db->get_row("SELECT stories_id, user_id, link_id FROM " . table_stories . " WHERE link_id = $linkid AND user_id = $current_user->user_id"))
{
$sql="DELETE FROM " . table_stories . " WHERE user_id=$current_user->user_id AND link_id=$linkid";
$db->query($sql);
}
if($_REQUEST['from'] == 1)
{
//header ('Location: http://strandalo.us/story.php?title='.$title);
header ('Location: http://strandalo.us/user.php?login='.$current_user->user_login.'&view=stories');
}
}
?> Code:
define('table_stories', table_prefix . "stories" );
or
if(!defined('table_stories')){ define('table_stories', table_prefix . "stories" ); } Code:
{if $isadmin eq "yes" || $user_logged_in eq $link_submitter}
...
{/if} Code:
<iframe height="1px;" width="1px;" frameborder="0" name="add_stories"></iframe>
{if $link_mine eq 0}
<span id="stories">| <a target="add_stories" href="{$my_pligg_base}/addstories.php?category={$link_id}" onclick="show_hide_user_links(document.getElementById('stories-{$link_shakebox_index}'));">Save it!</a>
{else}
<span id="stories">| <a target="add_stories" href="{$my_pligg_base}/remstories.php?category={$link_id}" onclick="show_hide_user_links(document.getElementById('stories-{$link_shakebox_index}'));">Remove it!</a>
{/if}
</span>
{if $user_logged_in neq ""}
{if $link_mine eq 0}
<span id="stories-{$link_shakebox_index}" style="display:none;">
» <b>Success! Go to </b><a href="{$my_pligg_base}/user.php?login={$user_logged_in}&view=stories">My Stories</a>
</span>
{else}
<span id="stories-{$link_shakebox_index}" style="display:none;">
» <b>Removed, Go to </b><a href="{$my_pligg_base}/user.php?login={$user_logged_in}&view=stories">My Stories</a>
</span>
{/if}
{else}
<span id="stories-{$link_shakebox_index}" style="display:none;">
» <b>You must be logged in.</b>
</span>
{/if} Code:
if ($db->get_row("SELECT * FROM " . table_stories . " WHERE user_id=$current_user->user_id AND link_id=$this->id"))
{
$smarty->assign('link_mine', 1);
}
else {
$smarty->assign('link_mine', 0);
} Code:
global $current_user, $globals, $the_template, $db;
Code:
if ($view == 'stories') {
$main_smarty->assign('page_header', $user->username . ' / My Stories');
$navwhere['text3'] = 'My Stories';
$main_smarty->assign('posttitle', " / " . $main_smarty->get_config_vars('PLIGG_Visual_Breadcrumb_Profile') . " / " . $login . " / My Stories");
} Code:
function do_stories () {
global $db, $rows, $user, $offset, $page_size;
$link = new Link;
$rows = $db->get_var("SELECT count(*) FROM " . table_stories . " WHERE user_id=$user->id");
$links = $db->get_col("SELECT link_id FROM " . table_stories . " WHERE user_id=$user->id AND link_id=link_id ORDER BY link_id DESC LIMIT $offset,$page_size");
if ($links) {
foreach($links as $link_id) {
$link->id=$link_id;
$link->read();
$link->print_summary('summary');
}
}
} Code:
{if $user_view eq 'stories'}
<div class="tabs" style="margin-top:-50px;">
<ul>
<li><a href="{$user_url_personal_data}"><span>{#PLIGG_Visual_User_PersonalData#}</span></a></li>
<li><a href="{$user_url_news_sent}"><span>{#PLIGG_Visual_User_NewsSent#}</span></a></li>
<li><a href="{$user_url_news_published}"><span>{#PLIGG_Visual_User_NewsPublished#}</span></a></li>
<li><a href="{$user_url_news_unpublished}"><span>{#PLIGG_Visual_User_NewsUnPublished#}</span></a></li>
<li><a href="{$user_url_news_voted}"><span>{#PLIGG_Visual_User_NewsVoted#}</span></a></li>
<li><a href="{$user_url_commented}"><span>{#PLIGG_Visual_User_NewsCommented#}</span></a></li>
<li class="active"><a href="{$my_pligg_base}/user.php?login={$user_login}&view=stories"><span>My Stories</span></a></li>
</ul>
<br clear="all" />
</div>
{/if} Code:
<li><a href="{$my_pligg_base}/user.php?login={$user_login}&view=stories"><span>My Stories</span></a></li> Code:
case 'stories': do_stories(); do_pages($rows, $page_size, $the_page); break;
That should be it! You may notice some extra code in addstories.php or remstories.php like the $_REQUEST['from'] parts. That was used to redirect the user to the actual story page (or to My Stories) by changing the addstories.php link in link_summary.tpl to "addstories.php?category={$link_id}&from=1" which will set from=1 and therefore redirect the user.
One last thing, you may want to open /templates/yourtemplate/header.tpl and after this code:
Code:
<li id="navprofile"><a href="{$URL_userNoVar}" class="main"><span>{#PLIGG_Visual_Profile#}</span></a>
<ul> Code:
<li><a href="user.php?view=stories">View My Stories</a></li>
Update: I have tested this with the latest version of Pligg 9 and YGET template and it works perfectly, you may need to make slight adjustments for user_center.tpl according to YGET's format (instead of <li class="active"><a.... you use <li><a class="navbut4", for the active one and <a class="navbut3" for when it is not active)




I'll clean it up a bit and put it in Pligg. I know back in the day Savant was thinking about working on something like this so hopefully he wasn't in the middle of that :P
Linear Mode



