Community Documentation

add pages to favorites and place them in a user specific menu.

Last updated May 14, 2012. Created by nielsvoo on May 11, 2012.
Log in to edit this page.

After a couple of years of building drupal sites i finaly want to give something back to the community, This tutorial is for Drupal 7

What are we gonna do?

This tutorial will learn you how to give your users the ability to add nodes to a list of favorites and show those in a menu.

First you need the following modules, so download them from the drupal site and install:

- Flag
- Views
- Views Flag Refresh

Now walk through the following steps:

1. Go to admin/structure/flags
2. Add a new flag using the following credentials:

- Name => favorites
- Title => Favorites
- Flag link text => Add to your favorites
- Flag link description => Add this item to your favorites
- Flagged message => This item is added to your favorites
- Unflag link text => Delete from favorites
- Unflag link description => Delete this item from your favorites
- Unflagged message => This item is deleted from your favorites

3. Now choose a role(s) this is necessary because you will display the menu of an loged in user.
4. Now at "Flaggable content" add nodetypes so users can flag them to favorites.
5. Choose the view options.
6. Choose Linktype => JavaScript toggle

Ok you just tuned the flag module now we build a view to get this all in action.

1. Build a new view of type content, add a page and a block.
2. first we build the block options with this credentials:

- Choose format of fields
- Add field "Title"
- Add filter "Published"
- Create a Relation to "Flags" choose here for Flag "Favorites" and only show flags for the curent user
- Choose Use AJAX "Yes" and connect "Refresh display on flags" to your item.
- Choose the pager items settings you want.

3. Now set up your page so users can click on a more link to see al their items, (how this works is discribed in many other tutorials)

4. Go to your block settings and connect the created block to your prefered region.
5. Now flag some content and check your menu.

------------------------------------------------------
Some extra cool action is possible by:

-adding some background images to your styles, when adding 2 stars one grey an one gold and connect those to the active status css class will give the users a direct view of the status of the node they are viewing.
- Add the module drupal beautytips to your site so a balloon will show a help text when flagging a node.

Succes!!!
Niels

Comments

Add views to favorites

Hi,

Thank you for the walk-through. I would like to know if there is a way we can add views also to favorites and not just nodes.

Thanks.

 
Sarat
Drupal Geek at New Target Inc.
http://www.newtarget.com

Probably not

Dear Sarat,

I don't think that is possible because the flag module only can flag nodes, comments, and (when using the flag friend module) also users. flagging views isn't possible.

Niels

Any other way

Thank you for your response Niels. Do you know of any other module/way using which views can be bookmarked as favorites.

 
Sarat
Drupal Geek at New Target Inc.
http://www.newtarget.com

maybe mark could do this for you

You can try: http://drupal.org/project/mark/

or although in dev status maybe this one: http://drupal.org/project/flag_page

Niels

Will try that

Thank you niels. Mark doesn't seem to be doing what I want, will try the flag page.

EDIT: Flag page seems to be working fine so far, I also added my own custom module that creates a tab called Favorites on the user profile page that lists all the pages that have been marked as favorites by the user along with delete buttons next to them so that they can the remove favorites they dont want anymore from the list.

 
Sarat
Drupal Geek at New Target Inc.
http://www.newtarget.com

Page status

No known problems

Log in to edit this page

About this page

Drupal version
Drupal 7.x
Audience
Site administrators
Level
Intermediate
Keywords
favorites list, User menu

Site Building Guide

Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.
nobody click here