I have a node #1 of content type A. If the user equals a certain role AND has not yet done the following, show a link within node#1 saying "create node of type B".

If the user clicks this link, he may create a new node of type B. Then, when looking at node#1 again, the link disappears (or changes), since the user has already created another node from within node#1.

If you would delete that last created node and visit node#1 again, you would again have the possibility to create a node of type B which would automatically be related to the respective node, in this case node#1.

How can you do that?

1 Answer 1


I can see couple of ways to do it.

1) add the module http://drupal.org/project/node_limit

2) Create a menu with node/add/contentA

3) add this block to the node of the type content A

4) to do the third step you would need to add alias to the content A nodes by following method

Setup a URL alias pattern for content A Click on Configuration in the admin menu, and look for "URL Aliases". One of the tabs is called "Patterns" - this is where you can adjust the automatic URL alias settings for your content. In the "Content Paths" section you'll see the default is set to "content[node:title]" -- just below that you'll want to set "Pattern for all Blog entry paths" to "contenta/[node:title]" and save your new configuration. This means all of your future Content A content will have URLs like: http://yoursite.com/contenta/your-contenta-title.

(Thanks to Jonathan Webb http://www.drupalgardens.com/content/block-not-showing)

That should do it.

This assumes that the user can only add one node.

EDIT : An update with the requirement mentioned in the comment

Instead of step 1 and 2 do the following

1) Enable php filter

2) Create a view of the type block with just one field may be nid of the node. Remove the label. Rewrite the out put to some thing like so that nothing is displayed.

3) Add contextual filter of the type content:author and select provide default value and from the drop down select User ID from logged in user

4) In the header section add a field of the type gloal:textarea click on "Display even if view has no result" so that it would be displayed even if there is no result.

5) Select PHP code as the filter and paste the following code with the changes that suite your requirement such as changing the url to the one that adds your content type.

  $view = views_get_current_view();

   if (!count($view->result))
       print "<a href='" . base_path() . "node/add/book'>Add Node</a>";

Follow step 3 and 4 to add the block to the node.

  • Thats not exactly what i was searching for. Every user may create a node of type b for each existing node of type a.
    – Alex
    Commented Jan 18, 2013 at 8:34
  • So if there is a user x and there are two contents of the type a then user x should be able to create 1 content of the type b for each of the existing 2 content 1 type. Commented Jan 18, 2013 at 8:38
  • exactly. sorry if i have not been clear before. but the goal is to have user group A to create nodes of type A. users of type B may "answer" those nodes each by creating a node of type B (response/answer) once per node of type A. so a node of type A can have several "answers" of type B, but each user B can only create one node B for each node of type A
    – Alex
    Commented Jan 18, 2013 at 11:02
  • I have edited the answer to make the changes you mentioned. Hope that helps Commented Jan 18, 2013 at 11:05
  • Thanks so much for your response! That might work but wouldnt it be nicer to control that model data from within a module instead of doing that in the view layer?
    – Alex
    Commented Jan 18, 2013 at 12:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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