This Article will explain how the Favorite’s Module Works.
The following sections will be covered in this article:
● Module Dependencies (tables in the database, libraries, etc), that a site must have for this module to work properly.
● The Overall Logic (The Favorites module).
● Widgets Involved.
● Website Settings Involved.
● The CODE (JS & PHP)
1. Database Table “users_favorites”.
● id = ID of each favorite.2. Member Feature “Favorites”
● userId = ID of the member that press the favorite button.
● ownerId = ID of the member that made a Feature Post.
● postId = ID of each feature post.
● dataType = Data type of each Member Feature (Custom,Listing, etc)
● featureId = ID of each Member Feature.
● checked = Its currently not use. For future options.
● Needs to Create a new Member Feature. You can named anyway you want, but the Data Type needs to be Favorites.3. Favorites Widgets.
● Bootstrap Theme Display Add to Favorites Button. (Display)4. Bootstrap Theme Subscription Form.
● Bootstrap Theme Function Add to Favorites Button. (Engine)
● Bootstrap Theme Account Sidebar. (Member Dashboard Section in Sidebar)
● Bootstrap Theme Member Profile Header. (Profile Page)
● All Membership Features that use it in their Search Results and Detail Pages
5. Membership Level Bootstrap Form
○ favButton Field in form (Boolean and used to verify the membership level with the favorite button backend code)
These are the steps that the system takes to create a New Favorite
1. The System displays a Heart Button on each Feature Post.
2. You need to be Logged in to the System to favorite. If you are not logged in a modal displays in order to login into the Site.
3. Before the favorites button creation, the system loads a Span Tag that contains all the information related to each Feature Post which in turn is used by the favorite button to gather the information needed when a user clicks on it. You can always see the Span Tag above the favorite heart shaped button in the code.
This information is very important, because this is how the heart knows what to add into the Database. If the span is missing, it means that either the Membership Feature does not have the correct code in the search results or in the details page, or that the Bootstrap Theme Member Profile Header does not have the correct information in it. Careful consideration should be taken since depending on the membership feature, the code for the span could change between 3 types that use either the $post, $p or $group variables.
5. To see which favorites you have, you would go to your Member Dashboard and click on your Favorites Tab in the sidebar. Here you are able to see which type of favorites you have and how many.
6. Finally in the same Member Dashboard area you can Delete the Favorite and View the Details Post of your Favorite.
1. Bootstrap Theme Display Add to Favorites Button: Make the Front End Functionality of the Favorites Module.
2. Bootstrap Theme Function Add to Favorites Button: Make the Back End functionality of the Favorites Module.
3. Bootstrap Theme Account Sidebar: Creates the Favorite Sidebar option menu in the Member Dashboard.
4. Bootstrap Theme Member Profile Header: Creates the span needed for the special case of profile pages.
5. Additionally to the widgets previously mentioned, all membership features will need a special code to be added to them in order for the favorite button to work in their Search Results and Detail Pages. This code adds the span used by the favorite button.
WEBSITE SETTINGS INVOLVED
After adding the Favorites Feature to your site, the only setting needed is the Favorite option inside the Membership Levels. If a membership level has the favorite option enabled, you will see it on the Active Features list:
To enable or disable this option you would only need to go to Features tab inside the Membership Level and toggle it.
Note that if ALL membership levels have the Favorite option disabled, the favorite button will disappear from the frontend (Will not show on any page). The site needs to have at least 1 membership level with the favorite option enabled in order to show on any of the pages it is used on.
Additionally, disabling the favorite option for a particular membership level will only disallow favoring for all members on that particular membership level, but they will still be able to see the favorite button on the pages they visit. They would just get an “Upgrade” modal if they happen to click on the favorite button.
The JS part of the code is the middleware between the user interaction and the PHP code for the favorite button. It verifies for example:
● If user is logged in
● If user has correct permissions
● What page the user is viewing
● Enable or disable the favorite button depending on user interaction
● Validate specific information to be send to the engine (Which in turn validates the information again)
● Creates a modal as a response for a user that is not logged in or does not have permissions to favor.
● Checks the data needed by a favorite button when clicked (Verifies the span tag)
● Denies favorite button functionality when span tag is missing
The PHP code is a single engine that verifies input and depending on it, returns specific types of output. This input and output can be:
● Clicking the favorite button
● Verifying user does not already have favorite post in database lis
● Adding favored post to the list
● Checking to see which favored posts a specific member has
● Returning a table with all favorites for a member
● Execute MySQL statements for Insert, Select and Delete
● Removing favored post from the list (If clicked on the favorite button again)
● Checking for correct input values
● Returning a list of favored posts based on the page viewed
● REST API (ClientServer) to manage calls (input) and return what is needed (output)