Hello!

I'm currently building a social network on drupal7 and chose profile2 as my starting point for user profiles. Here's a summary of my experience.

The ability to create profile types and bind them to users was relatively painless, very few problems there. I did have issues with contrib field modules recognizing profile2 entities and behaving themselves, like imagefield crop.

The api functions for loading and saving profile2 objects was pretty painless, everything went smoothly.

However, I've ran into a significant sticking point; searches and views. Because profile2 objects are not nodes, there are several problems that arise when building views around that data.

1. I cannot create an aggregated search view of all profiles along side other content. This is a vital feature for a social network. I need to be able to search "John Smith" within a view, find John Smith's profile, and any other nodes with that keyword in a single view.

2. To create any kind of search, I need to use SearchAPI, which unfortunately does not play nice with profile2; I can't gain access to all the fields. On top of all that, I still can't create a aggregated search of nodes and profiles using SearchAPI.

What I'll likely have to do is create my own version of drupal6's content profile, as much as it pains me to do so. As cool as the entity thing is, there are some serious drawbacks with how it interacts with views and drupal's default search engine. What's really unfortunate, is even if profile2 could hook into drupal's default search engine, views is not advanced enough to display data from more than 1 entity at once :(

Comments

Sinan Erdem’s picture

On the module homepage it says at the bottom of description:

You may use Views and/or the Search API to provide listings or searches for profiles.

Isn't it a true statement then? Or the fields of a profile is not available on a view?

I am considering to use Profile2 also, and this issue may be a problem...

terbs’s picture

It's not a false statement, it's just the method in which you have to build your views and searches is what gave me problems. I couldn't get image or file fields to show up in my SearchAPI view, and because of the way Search APIs views need to be structured, it was impossible for me to build a view that showed all profiles along side other types of content.

Just make sure you research the module thoroughly before deciding to build with it.

PedroMiguel’s picture

This module dont solve your problems with views? http://drupal.org/project/views_cross_join

I'm building a social-ish network site type also, just start looking existing modules...

cjwest’s picture

I'm running into an interesting problem where when creating a view, some of the data from the profile2 fields doesn't show up in the view. I'm finding the fields in views okay, however. Anyone able to shed some light here?

terbs’s picture

That module is sweet! Nice find. Unfortunately since profile2 doesn't let drupal's default search indexing run on its entities, search keyword fields still don't work properly. Maybe if cross-join was combined with SearchAPI you could get good results, but that seems like a tower of cards.

medhatushar’s picture

that happens if u select field from different profile type then they dose not show the proper field data . u can create search view with the same profile type then it will work fine ... i hope..

SomethingOn’s picture

I'd really like to see Profile values included in Drupal's default search index. Default search works in most cases, but missing the profile fields really sucks. The Search API and all of the other required modules seems like so much work/overhead for something like this...

iRex’s picture

Hey aiquandol - was just wondering if you had managed to find your way around the limitations of the Profile2 module. I have been thinking of building a social network with D7....

terbs’s picture

Hey iRex,

No I never did. I ended up dropping Profile2 and built a custom module that mimics the behavior of modules like nodeprofile(drupal 5) and content profile(drupal 6), where the profile is a node owned by a user. Since I couldn't find any good solutions for showing multiple types of entities in the same view and the standard drupal search doesn't work on entities other than nodes, I had to revert to using nodes for my user profiles. If you don't need multiple types of profiles you can just use drupal 7's standard user object and add new fields to it to build most social networks.

klucid’s picture

Thanks for your insight, iRex. So just to clarify, if we only need one profile, we should ditch Profile2 and just add fields to the user account?

Thanks again!

iRex’s picture

@klucid, I believe you are responding to acquandol's comments. But, yes, if you need to create one profile that would seem to be one way to go

klucid’s picture

Heh, sorry about that. I had been hacking at this keyboard for over 12 hours and running on fumes. Thanks for your reply. :)

tommeir’s picture

I just implemented something similar using multiple profile2 types and search api. what u want should be
possible with https://drupal.org/project/search_api_multi to allow searching over multiple entities (across different indexes at once) over views.

Jarada’s picture

I managed to get an aggregated view based upon using Profile2 with Search API and Views. To achieve this, do the following:

First, create an index that uses an item type of User, not Profile or Profile type. Then, when you are selecting the fields to index for this index, go to the bottom and select add related fields, and add the profiles you would like to be able to search on. Doing this will add all profile field information for each profile type onto the table above. You will then want to check the appropriate profile fields against the appropriate profile type, along with any other search information related to the user. You can then create a view using this index.

Doing this based upon the user rather than the profile or profile type aggregates your results based upon the user rather than an individual profile entry. Thus, you can show profile information alongside other content from the user object. This should help anyone who wants to create a User centric search with Profile2 data.

bisonbleu’s picture

I was facing the same daunting issue - create a single View from which to search for nodes and/or profile2s. I don't have access to Solr. I only have access to a Service class: Database service. After reading READMEs and testing, I really thought I was in a black hole with no way out.

But @tommeir is right. Although the search_api_multi README says that only the Solr search is supported, that has since changed thanks to @drunken monkey. See Add possibility to search indexes on any server.

So, if you enable search_api_views and search_api_multi, you can from a single view search multiple indexes running on a Database service server.