As with anything drupal, there are a million different ways to do something. I am asking this question for 1) Because I actually have to do something similar and 2) Because I would like to know all the different ways this could be achieved and the pros and cons of each. Is creating a custom field the way to go or should you just dump some dynamic code in the node-album.tpl.php template? Which way is the most flexible? Which is the most non-coder friendly?

Scenario: You have two content types (say, photo and album) where photo has a file field for an image and album is a collection of photo nodes.

If a user is viewing an album node type, how would you go about creating a "add photo" link on the full node view to add a photo to that specific album? Using the entity reference prepopulate module.

So how would you give users a way to click on a link/button for:


1 Answer 1


This is how I do mine if it's entity reference prepopulate:

        $l = l( t('Add Photo'), 'node/add/photo',   array('query' => array('field_album_reference' => $nid)  ));
        echo $l; 

But I usually use node reference widget when for example adding an album coming from venue content type. Code example:

<a href="<?php print url('node/add/venue-photo-album/' . $node->nid); ?>">Add Photo album</a> 

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.