I am getting this error when submitting to nodefamily:

Fatal error: Only variables can be passed by reference in /var/www/vhosts/baade.org/httpdocs/sites/www.baade.org/modules/nodefamily/nodefamily.module on line 481

The line referred to (line 481) is this:

return nodefamily_relation_load(node_load($node));

I'm using Apache (Linux) 2.0.54, PHP 5.0.4 and mySQL 4.1.11

Comments

fago’s picture

StatusFileSize
new1.18 KB

ah thanks.

does the attached patch fix the problem for you?

gmak’s picture

does the attached patch fix the problem for you?

Yes, and no. It fixes the error on line 481. But throws the same error at line 508:

Fatal error: Only variables can be passed by reference in /path to my site/modules/nodefamily/nodefamily.module on line 508

This happens even though I see that your patch has changed the code at line 508.

fago’s picture

Are you sure, that you have applied the patch correctly?
The code on line 481 is exactly the same as the code on line 508, so there can't be any difference.

Have you tried nodefamily_relation_load_by_type() and nodefamily_relation_load() or only one of them?

gmak’s picture

Okay, I've figured something out. It seems that the problem is in this code from the examples:

$children = nodefamily_relation_load_by_type($nid);

or

$children = nodefamily_relation_load($nid);

If I have this in a template, it throws the errors. If I don't use a template it does not throw any errors and displays the correct information.

Just to make clear, I'm using nodefamily, usernode and nodeprofile. I have created a CCK type called 'content-personal_information' and associated this with usernode. I create content for the 'content-personal_information' and then follow the link from 'my account' page to the node which corresponds to the usernode. that's when the error appears.

fago’s picture

StatusFileSize
new1.23 KB

yeah, this code is only in this functions. so the above fix fails too.

please try this one, it should work now. however it's strange, because I'm using php5 too (php 5.1.6)

gmak’s picture

StatusFileSize
new16.83 KB

Well, there is some improvement (I think), but I'm still not seeing what I should.

if in my template I use $children = nodefamily_relation_load_by_type($nid); I don't get any errors but I also don't get any output - just a blank content area

if I use $children = nodefamily_relation_load($nid); it throws the error at line 483.

Also, the patch did not seem to apply properly but didn't give any fail notifications. So, I fixed it by hand. I attach it here so you can check to see if maybe something didn't get done properly.

Thanks for your help with this. I hope we can find a solution soon.

fago’s picture

your patched module looks fine.

the function call loads only the related nodes, to output them you have to do something like that:

   e.g. use this to print the teaser of the first child node:
   <?php print node_view($children[0], TRUE, FALSE, TRUE); ?>

   or this to print the full node view of all children:
   <?php
      foreach ($children as $childnode) {
        print node_view($childnode);
      }
?>
gmak’s picture

That's exactly what I'm doing. Here is my template file:

<?php

$children = nodefamily_relation_load_by_type($nid);

foreach ($children as $childnode) {
        print node_view($childnode);
      }
?>

This results in a page with no content.

If I change it to this:

<?php

$children = nodefamily_relation_load_by_type($nid);

print node_view($children[0], TRUE, FALSE, TRUE);

?>

I get simply "n/a" appearing in the content area.

If I do not use my template file, and let drupal simply render the CCK through the normal node.tpl.php, I see what I should in the content area.

It seems to mee that the $children = nodefamily_relation_load_by_type($nid); is not getting the correct return for some reason.

fago’s picture

probably there aren't any children.

have you set up any relations for your content type? you can check wheter nodefamily has created a relation in the "nodefamily" table with phpmyadmin or so..

gmak’s picture

StatusFileSize
new12.53 KB

There are children. See the attached jpg from phpMyAdmin. I just opened these individually in my browser and they correspond to the two pages that are associated with my username. You can check these at http://www.baade.org/node/236, and then follow on to node/394.

I'm going to try setting things up for another user and see what happens.

gmak’s picture

OK, just tried it with a different user and the same results.

The nodefamily table is updated with the relevant fields.

The output on the template page is exactly the same; either "n/a" or no output.

Very odd.

fago’s picture

hm, yeah node 394 is child of the usernode 236. but are there any childs of node 394? probably not, so there is nothing to display.

you could theme the usernode to display the content of node 394 inside the usernode instead of showing a link.

gmak’s picture

ahhh, now that makes some sense. Maybe this isn't as clear as it could be in the documentation or a more expanded tutorial/how-to would help.

Thanks for your help. I'll let you know how I get on.

gmak’s picture

Still having problems.

I have now created another CCK type ('content-course_information'). I have created a nodefamily relation between this CCK type and the other CCK type. So, I now have nodefamily relationships that look like:

Usernode > content-personal_information
content-personal_information > content-course_information

If I'm not mistaken this should mean that when I look at the output from my template (for content-personal_information), which includes:

<?php
$children = nodefamily_relation_load($nid);

foreach ($children as $childnode) {
        print node_view($childnode);
      }
?>

I should the data from both content types. But, I'm seeing the output for the personal_information type (which is being pulled in directly to the template), but I am not seeing the 'child' content (course_information).

Looking in the database I see that the relations are there.

Again, using nodefamily_relation_load throws an error (line 483). While using nodefamily_relation_load_by_type results in no output.

fago’s picture

ah, change your line 483, so that the few lines look like this:

function nodefamily_relation_load(&$node) {

  if (!is_object($node)) {
    //$node is the nid
    $node2 = node_load($node);
    return nodefamily_relation_load($node2);
  }
..

The nodefamily_relation_load_by_type() function generates different arrays, so you would have to change your output code to:

foreach ($children as $type => $nodes) {
  foreach ($nodes as $node) {
        print node_view($childnode);
  }
}

for this function.

fago’s picture

ahm of course it has to be

foreach ($children as $type => $nodes) {
foreach ($nodes as $childnode) {
print node_view($childnode);
}
}

fago’s picture

Status: Active » Fixed

Commited to HEAD.

So you can also check out the latest nodefamily.module.

Anonymous’s picture

Status: Fixed » Closed (fixed)