[development] Node referencing

Sergio lsmoura at gmail.com
Wed Nov 16 16:10:16 UTC 2005


I don't have a DIFF here, but here it goes...
I tweaked the node.module a bit (4.6.3) so the I could make the
/node/add/<type>/<parameter> works and I get the desires result... This need
to be tweaked further so that more parameters can be added...

function node_page() {
(...)
case 'add':
print theme('page', node_add(arg(2), arg(3)));
break;
(...)

function node_add($type, $_extra = 0) {
(...)
}
$output = node_form($node, $_extra);
drupal_set_title(t('Submit %name', array('%name' => node_invoke($node,
'node_name'))));
(...)

function node_form($edit, $_extra = 0) {
(...)
if (function_exists($function)) {
if ($_extra)
$form .= $function($edit, $param, $_extra);
else
$form .= $function($edit, $param);
}
(...)

function B_form(&$node, &$param, $nidA = 0)


That does the trick... But as I don't think that this is the desired
function of node.module, I will try and write my code another way so that it
stays compatible with the official version... Altough I get no warnings with
the above changes (so far).

Back to the module coding now...
Thanks all

- Sergio


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/5b174079/attachment.htm


More information about the development mailing list