Question:

How to bookmark articles to user profile?

Naomi: 2 weeks ago

We are developing a Joomla site where different types of articles will be posted and the users will bookmark the article to their user account and display it in their user profile.

If there is a recommended way to create this function or coding we are ready to do that, if not is there any module supporting this feature?

The table format for this bookmark feature is

arti_id | date_added | user_id | time_added | status 

the
arti_id -> Aritcal ID
status -> Public / Private

Others are common.

Answer:
Riley: 2 weeks ago

Personally, I would suggest you create a plugin for this.

I'm not going to write it out for you, but will show you the concept.

  1. Create your base plugin and to help, follow the documentation here (https://docs.joomla.org/J3.x:Creating_a_Plugin_for_Joomla)
  2. Create your database table with the columns you specified in your question.
  3. Your first function will need to add a bookmark button to all articles and should be done using the onContentPrepare (https://docs.joomla.org/Plugin/Events/Content#onContentPrepare) event.
  4. The second function should capture the button click and run a database query (https://docs.joomla.org/Inserting,_Updating_and_Removing_data_using_JDatabase) to add the bookmark. You can caption the user object (http://docs.joomla.org/Accessing_the_current_user_object) and ID easily using the code below:

    $user = JFactory::getUser();
    $user_id = $user->id;
    

I assume you will also want to display a user's bookmarks somewhere. For this, I would suggest creating a simply modules that runs a database query, getting all results which match the $user->id; with the ID in user_id column in your database.

Hope this points you in the right direction