[development] Node referencing

Earl Dunovant prometheus6 at gmail.com
Wed Nov 16 17:07:28 UTC 2005


Assuming /node/add/B?mainnode=5, something like this should work.

function B_form(&$node, &$params) {
$mainnode = $_GET['mainnode'];
// make sure it's a valid node for the purpose
if (nid_passes_the_test($mainnode) {
$node->mainnode = $mainnode;
}
else {
// yell at them for making an error
}
...
}



On 11/16/05, Sergio <lsmoura at gmail.com> wrote:
>
> Earl,
> I tought about that...
>
> I have a ?q=node/add/B/5 and I changed the hook_form to function
> B_form(&$node, &$param, $nidA = 0) But I don't get the desired result... The
> page at drupaldocs
> http://drupaldocs.org/api/4.6/function/page_example_menu says that the
> 'extra' parameters will be passed as arguments to the function, but it seems
> that those don't get to the hook_form function. Is there any way to create a
> custom function and re-create the form as the node/add/B would do? That way
> I could create the form and it would work transparently to the user...
> Also, is it that the desired hook_form behavior? Have I found a bug? :-)
>
> Thanks for the help...
>
> On 11/16/05, Earl Dunovant < prometheus6 at gmail.com> wrote:
> >
> > You just need to get the nid of the main node into the creation of the
> > subordinate node typoes. How about using a query string to specify the
> > parent, like
> >
> > node/add/B?mainnode=(nid of A)
> >
> > or maybe
> >
> > node/add/B/(nid of A)
> >
> > Populate the new field in hook_form(). You can even choose to show an
> > input control for the field if it's not specified
> >
> > On 11/16/05, Sergio <lsmoura at gmail.com> wrote:
> > >
> > > Hello, folks,
> > > I'm in need of a little help...
> > > I have a module with 3 types of node. Node A, B and C.
> > > I am trying to do something like A is the main node and B & C
> > > references A. So that, when I show the node A (teaser or full node), I get
> > > some informations about nodes type B and C that makes reference to A.
> > > Also, I want to node types B and C have a reference to the parent (A).
> > > When the user inserts the data, it must be transparent to him as who
> > > the parent is (like there is a link on node type A that allows the user to
> > > create type B or C and the node creation page will not ask the user who the
> > > parent is). The only creation method shoud be like this for nodes B and C
> > > (there should not have a link on the node creation list. Just for type A)
> > >
> > > I took a look at the project module, but I couldn't get much out of
> > > it...
> > > Any help is appreciated...
> > >
> > > Thanks,
> > > - Luis Sergio Moura
> > >
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20051116/3f688df7/attachment-0001.htm


More information about the development mailing list