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.

Job Interview's picture

It's actually a nice and useful piece of info. I'm glad that you just shared this useful info with us.

Please keep us up to date like this. Thanks for sharing.

Taj's picture

What's up Dear, are you genuinely visiting this website regularly, if so
afterward you will absolutely get good experience.

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.

Guillermo Valls RTVE's picture

Wow, this paragraph is nice, my younger sister is analyzing these kinds of things, thus I am going to convey her.

Aquarium air laut's picture

Everything is very open with a precise description of the challenges.
It was really informative. Your site is very helpful. Thank you
for sharing!'s picture

I do not even know how I ended up here, but I thought this post was great.
I do not know who you are but certainly you're going
to a famous blogger if you aren't already ;) Cheers!

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!

farmville 2 cheatsfarmville 2 hackfarmville 2 cheat engine's picture

Some of their items incorporatelotions and soaps, therapeutic massage balms, scents, lip glosses and balms,
body butters and shea butter. Moreover, college students are nott 'dumb' when itt comes
to the problems of whwt local Eugene writer dubbed as 'technology leads to grave
robbing. Click "Convert" button to start converting AVI to MPEG-4 for Android

Feel free to visit my web site - farmville 2 cheatsfarmville 2 hackfarmville 2 cheat engine

how to look like a soccer player's picture

Wonderful work! This is the type of info that should
be shared around the web. Shame on Google for no longer positioning this publish upper!
Come on over and visit my web site . Thank you =)

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.

Johna16's picture

An interesting dialogue is value comment. I feel that it is best to write extra on this subject, it won't be a taboo subject but generally persons are not sufficient to speak on such topics. To the next. Cheers eekeaddfdded

Post new comment