Skip directly to content

Pass nid as argument in URL path when opening node add form in a ctools modal frame

on May 11th, 2012 at 7:21:49 AM

Here is the best tutorial I found in the internet to open a "node add" form in a Ctools modal frame (with Drupal 7):

What we want to do is pass an argument through the Ctools modale frame URL path and inject it in a Entity/Node reference field. Before coding we need to install one of the following module: Entityreference prepopulate or Node Reference URL Widget. What both modules are doing is checking if a node NID is present in the URL path from your browser and if so, it will be passed to the form you are opening to prepopulate a field.
To make it appened, the module needs to get the node NID from an "add node" link you have in a custom block, for example. When you need that this link open in a Ctools modale frame, you'll probably have use the ctools_modal_text_button function.

From the aboved mentioned tutorial, in the sidebar_link() function we will change:

= ctools_modal_text_button(t('Submit an event'), 'create/nojs/public-event', 'public-event');


= arg(1);
// get the node nid from the URL
  $link_modal = ctools_modal_text_button(t('Submit an event'), 'create/nojs/public-event?field_you_want_to_prepopulate='.$arg1, 'public-event');
$output = str_replace (array('%3F', '%3D'), array('?', '='), $link_modal);


Comments's picture

I am really thankful to the holder of this website who has shared this fantastic piece of writing at at this time.

Winston Degroat's picture

Wow, superb blog structure! How long have you ever been blogging for?
you make blogging glance easy. The entire glance of your site
is excellent, let alone the content!


Awesome article.

Johna634's picture

Hi there. Simply just planned to request a simple dilemma. ebedkefackec's picture

Thanks in favorr of sharing such a fastidious opinion, posst iis fastidious, thats wwhy i have read it entirely

Also visit my web blog Employee engqgement coommunication - [url=][/url] -

castle clash cheats's picture

At this time it seems like Drupal is the top blogging platform
out there right now. (from what I've read) Is that what you are using on your blog?

my weblog ... [url=]castle clash cheats[/url]

Carin's picture

Excellent site you've got here.. It's hard to find quality
writing like yours these days. I honestly appreciate people like you!

Take care!!

California News's picture

Thanks in favor of sharing such a good thought, paragraph is pleasant, thats why i
have read it fully

Cheap High PR Tumblr Blogs's picture


I would like to let you know that we are selling high
PR Tumblr blogs. I think as a webmaster, you know the importance of having backlinks from high PR blogs.
And you also know how costly it can be to have backlinks to this
high PR blogs.

Well I would like to inivte you and take a look at
our offer. At very cheap price, you can have your own high PR Tumblr were
you can use as backlinks to your site.

If your interested, please visit:


Post new comment