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!

kostenloses Girokonto's picture

Hello! I realize this is somewhat off-topic but I had to ask.
Does managing a well-established blog such as yours require a lot of work?
I am completely new to running a blog but I do write in my journal daily.
I'd like to start a blog so I will be able to share
my experience and thoughts online. Please let me know if
you have any kind of suggestions or tips for brand new aspiring blog owners.

seovolución's picture

Thanks designed for sharing such a nice thinking, paragraph is nice, thats why i have read it fully

andrege's picture

Attractive part of content material. I just stumbled upon your web site and in accession capital to claim that I acquire in fact enjoyed account your weblog posts. Any way I’ll be subscribing to your feeds and even I achievement you get entry to constantly quickly.

firme dezinsectie

seo adelaide's picture

This is my first time pay a visit at here and i
am in fact impressed to read everthing at one place.

Ozil's picture

What i do not realize is actually how you are not
really a lot more neatly-liked than you might be right
now. You're very intelligent. You already know therefore
considerably in the case of this topic, made
me for my part consider it from numerous varied angles.
Its like men and women don't seem to be involved unless it is one thing to accomplish with Lady
gaga! Your individual stuffs excellent. At all times maintain it up!

koodawg's picture

Ah! This"Here is the best tutorial I found in the internet to open a "node add" form in a Ctools modal frame (with Drupal 7): "is just what I need but the link is broken. Anyone know where something else like this is? Thx.

Post new comment