Favorites
From Online Business Wiki
Click on + to expand the category
Favorites allows your website visitors and/or customers to add items of importance to them to their favorites list. Customer are able to add just about anything to their favorites these includes: Products, FAQs, Web App Items, Announcements, Bookings and so forth. Once added to their favorites list, customers can peruse them by logging in into a secure zone. They can also remove any added items from this list.
You can get started by simply adding {tag_addtofavorites} to the List or Details layout of your online shop, FAQs and so forth. To do this go to Admin -> More Customization Options. Go into a layout and simply paste {tag_addtofavorites} in. If you would like to user your own images for the 'add to favorites' and 'remove from favourites' buttons, then you will need to append the image sources to the end of the add to favorites tag as below:
{tag_addtofavorites,addtoImage,removefromImage}
For example:
{tag_addtofavorites,<img src="/images/addtofav.jpg" />,<img src="/images/removefromfav.jpg" />}
NOTE: If you are going to use images for the add to favorites button, you need to specify both a 'add to favorites' and 'remove from favorites' image otherwise this image will not change even if the customer has the item already listed in their favorites.
For customers to be able to view their favorite items you need to place the favorites module {module_favorites,a,0,0} onto the page within the secure zone. You can either paste the module from this article or you can go to the Module Manager -> Secure Zones -> Favorite list.
When the link is rendered on the page it will look like like the one in the screenshot below -
Listing favorites by module type
The following are the modules that will list the favorites in a particular feature:
List of all favorites: {module_favorites,a,0,0}
List of favorite announcements: {module_favorites,a,7,0}
List of favorite Products: {module_favorites,a,27,0}
List of favorite FAQs: {module_favorites,a,9,0}
List of favorite bookings: {module_favorites,a,48,0}
List of favorite web app items: {module_favorites,a,35,0}
List of favorite web app items in a particular web app: {module_favorites,a,35,56}
Automatically adding the item to favorites
You can using a simple JavaScript function add an item to a customer's Favorite's list. Note for this to work, the customer needs to be logged in to your website since we need to know whom we adding the item to.
To do this, simply append the following code to your page:
<script type="text/javascript" src="/ajaxpro/prototype.ashx"></script> <script type="text/javascript" src="/ajaxpro/core.ashx"></script> <script type="text/javascript" src="/ajaxpro/converter.ashx"></script> <script type="text/javascript" src="/ajaxpro/CMS.FavoriteProcess,Catalyst.Web.CMS.ashx"></script>
Then your JavaScript will look something like this:
<script type="text/javascript">
function AddToFavorites() {
var objectId = '{ tag_itemid}';
var objectType = 35;
var result = CMS.FavoriteProcess.ServerSideAddToFavorites(objectId, objectType);
// result is boolean, true or false
}
Now, when the form is submitted, in the validation function simply call the function above first before submitting the form!


