1

I have created a role, and have added additional fields to their profile using Profile 2. The fields are part of the location module, and are just basic contact info (address and phone number). They are also able to chose a name, which is used in the url for both their profile and content.

So, when a user creates their account, the url is site.com/their-name. When the user adds content the URL is site.com/their-name/content.

My goal is to display their contact info in a block on all pages they publish. I was able to do this for their profile page with the following view (see attached image). However, I would like this block to appear on all pieces of content that they author.

enter image description here

0

You should take a look at the Context module.

Context allows you to manage contextual conditions and reactions for different portions of your site. You can think of each context as representing a "section" of your site. For each context, you can choose the conditions that trigger this context to be active and choose different aspects of Drupal that should react to this active context.

Think of conditions as a set of rules that are checked during page load to see what context is active. Any reactions that are associated with active contexts are then fired.

Or a simpler solution might be to change your path from "their-name/content" to "user/their-name/content" and only show the block on "user/*/content".

| improve this answer | |
  • Thank you for the reply, Scott. The issue is that this block needs to be dynamic, and only show the contact information related to the author of the current node a user visits. So, if I am on user-name-a/content the block would display the contact information for user-name-a. If I am on user-name-b/content the block would display the contact information of user-name-b. Using contextual filters I am able to achieve this for the user's profile page, but none of the nodes they have published. – Stephen Martin Sep 10 '13 at 0:31
  • @StephenMartin, I thought you said you had the view and block working? – Scott Joudry Sep 10 '13 at 0:34
0

I think, you have not added correct contextual filter in the views. You should add Content: Nid contextual filters into your views, which will filter the current node, then add relationship Content: Author into your views which will add relationship between current node and its author.

| improve this answer | |
0

I ended up being able to figure it.

  1. Add Content:Author relationship.
  2. Add (author) User: Profile relationship.
  3. Add contextual filter (author) User: Uid
  4. WHEN THE FILTER VALUE IS NOT AVAILABLE > Provide default value > Content ID from URL
  5. Select "Also look for a node and use the node author"
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.