Navigation

Pligg Support

In this post:
http://pligg.com/support/question/bug-fix-for-the-sidebar-saved-story-module/#question
I fixed a bug in the sidebar_saved Module that was preventing it from loading and displaying the saved stories in the sidebar. The bug was fixed assuming that the purpose of the sidebar_saved module is to list 5 (or the set limit) links in the sidebar, no matter who the logged-in user is. See discussion post:
http://pligg.com/support/question/issue-with-saved-stories/#question
From the discussion in the provided link, I understood from YankiDank that the module was intended to show saved stories that were saved by the logged-in user. In this case, the result is not met.
If you want to show any set of saved stories no matter who saved them, then keep the module as is. However, if you want to only show the saved stories by the logged-in user, then this is the solution:
First, I could not find a Smarty variable for the logged-in user id, so I had to create one as follows:
1. Open \libs\smartyvariables.php
2. Go to line 44 or look for “$main_smarty->assign('user_logged_in', $current_user->user_login);” and paste this right after it:

$main_smarty->assign('user_logged_id', $current_user->user_id);
3. Save and close
4. Open \modules\sidebar_saved\templates\sidebar_saved_index.tpl
5. Go to line 22 or look for “global $the_template, $main_smarty, $db;”
6. Paste this right after it: (this is to import the smarty variable we created above to php and be able to use it.)
$user_logged_id = $main_smarty->get_template_vars('user_logged_id');
7. Change this query:
$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 AND link_author = link_author ORDER BY saved_id DESC limit 5";
To this:
$res = "select link_id,link_title,saved_id,saved_user_id,saved_link_id from test_links , test_saved_links WHERE saved_user_id =$user_logged_id and link_id = saved_link_id ORDER BY saved_id DESC limit 5";
8. Save and close
Now the saved stories in the sidebar will only show those belonging to the logged-in user.

Possible Answers

    I finally got around to adding this to Github. I made some slight adjustments to your code, the most notable being a variable name change from $user_logged_id to just $user_id.

    https://github.com/Pligg/pligg-cms/commit/17fb083ce61356dd506dec8ad359eafe2d2dc759

    | Posted 3 days ago | Permalink | Hide Replies

    Great, thanks for your follow up! :-)

    If you can take a look at my other posts, there are quite few things to also add to github.

    | Posted 2 days ago | Permalink | Hide Replies

Who Upvoted this Story

Pligg.com's Support area is where you can ask questions and get answers. Just getting started with the Support area? This section describes tips for participating.

Submitting a Question or Comment

By taking a minute to research previous posts you may receive an answer much faster than waiting for a response to a new question. Begin by searching the support section for an answer. Sometimes you may even want to extend your search to the entire pligg.com domain.

If you are unable to find a relevant answer, submit a new question or comment here. Please provide a detailed description and, when necessary, debugging information such as your server environment (a link to a <?php phypinfo(); ?> .php page would be very helpful), your web browser, and any steps necessary to reproduce your issue.

Submitting an Answer

If you have an answer or useful response that you would like to add to a post, you can submit it as a comment which other users will then vote on. Answers are sorted by most popular to least, allowing the best information to climb to the top of the page.

Please read and vote for existing answers before submitting your own, as there may already be an acceptable answer provided. You can use the "Reply" link found within an answer to submit a response to it, in case you want to expand or comment on someone else's contribution.

Including Files or Code

Sometimes it is necessary for you to attach a file or include a snippet of code for others to reference in your response. In most cases, you can .zip up files and attach them to a question or answer using Pligg's file manager. At times though this may fail, and in these circumstances we recommend using a third party host. Below we are including a list of recommended websites where you can share easily share file uploads (or snippets of code) through the web.