Goal: Create searchable member directory for a community website.
Outline: Use a custom field that allows members to decide if they want to be listed in the directory. Key a smart group off that field and have that smart group define a profile listing. Pick the fields you want in your member directory and make them part of the profile. Set all the permission right and away you go.
#1 What information will you display in your member directory?
We need to make three sets of fields: (a) the fields people can search the directory by (b) the fields that show up in the table view (c) the fields that show up in the detail view when you click on a specific member. Life is easiest if (a), (b) and (c) are the same. Still easy is (a) and (b) are the same.
#1a Searchable fields:
#1b Table view fields
NOTE: CiviCRM Profile listings shows the name by default. This is really just two fields.
#1c Detail view
#2 Create any custom fields you need.
Since we want to have users opt into the directory, we will create a yes/no custom field "List me in the public website member directory." Make sure to remember to make this custom field searchable.
If any of the fields you need in #1 are custom fields, create them now.
#3 Create the groups you need
We want to create a smart group which identifies all CiviCRM contacts that have entered "Yes" in the "List me in the public website member directory" custom field. (do an advanced search for all the yeses. From the drop down, select create new smart group). We'll name this smart group "Public Member Directory". This group visibility should be "Public User Pages and Listings".
#4 Create the data entry CiviCRM profiles
Users can enter their information either before or after they register with the website (by marking the profile for use during user registration and/or view/edit user account). We are going to assume that they fill out directory information when they first get their drupal account.
Create a new profile called "Member Info (entry)"
Set up the fields:
#5 Create the CiviCRM profiles for the directory listing
Create new profile called "Member Directory (Display)"
Used for should be "Profile" only
And pick the fields:
Note the searchable and in selector values. This basically defines what fields you can search on (searchable) and which fields are displayed in the actual membership directory list view (in selector).
#6 Create a link to your directory
We generally create drupal menu item to a civicrm URL: civicrm/profile?reset=1&force=1&gid=5
The force value controls whether the actual search results are displayed or not. force=1 displays your list of members. You can also hide the search box by using search=0
Go through like a regular user and verify everything works as you expect. Edit this wiki page with tips and more information.