0

I have 2 custom content types: Item for sale, and Bid (offer). The latter has a node reference URL to a node of the first content type.

I created a view (block) which shows the people with their offers.

screenshot

I need to edit this view in such a way that is will be only visible to the person who created the Item for sale (author of the first content type may only see this block).

How can I achieve this? I cant seem to find a way with contextual filters.

screenshot

2

Easiest way to do this:

  1. Add a content relationship for the node reference field (i.e. Content: field_item_for_sale_ref)
  2. Add another relationship for the Content Author and select the node reference field relationship from the dropdown list at the top of the window.
  3. Filter the view for the current logged in user by selecting the author relationship that was just created in step 2.

OR

  1. Add a content relationship for the node reference field (i.e. Content: field_item_for_sale_ref)
  2. Add a contextual filter for the Content: Author uid, select the node reference field relationship from the dropdown list (top of window), select: provide default argument of type: user id from logged in user

Either way the result is the same and it's what you need.

| improve this answer | |
1

You can restrain block visibility only to node's author in the block's visibility settings. For example select "Pages on which this PHP code returns TRUE (experts only)" and use the following code as a visibility criteria:

<?php

    global $user;
    $node = menu_get_object('node');
    if($node) {
       if ($user->uid == $node->uid) {
           return TRUE;
       }
    }
    return FALSE; 
| improve this answer | |
  • I'll try this as soon as I get home. I let you know if it solves my problem – wallace740 Mar 20 '12 at 8:47
0

I presume you are extracting the ID node on display from the current URL for use in a contextual filter? You should also be able to add a relationship to that node and then a filter for the author of that content type = current user. That way there'll be no results when anyone else views the page.

| 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.