this works for me:

    <?php $children = nodefamily_relation_load($nid); ?>
    <?php
      foreach ($children as $childnode) {
        print node_view($childnode);

this does not, and produces the following warnings:

    <?php $children = nodefamily_relation_load_by_type($nid); ?>
    <?php
      foreach ($children as $childnode) {
        print node_view($childnode);

warnings:

warning: Invalid argument supplied for foreach() in C:\home\user\public_html\drupal\modules\node\node.module on line 504. 
warning: implode() [function.implode]: Bad arguments. in C:\home\user\public_html\drupal\modules\node\node.module on line 508. 
user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 query: SELECT n.nid, n.vid, n.type, n.status, n.created, n.changed, n.comment, n.promote, n.sticky, r.timestamp AS revision_timestamp, r.title, r.body, r.teaser, r.log, r.format, u.uid, u.name, u.picture, u.data FROM node n INNER JOIN users u ON u.uid = n.uid INNER JOIN node_revisions r ON r.vid = n.vid WHERE in C:\home\user\public_html\drupal\includes\database.mysql.inc on line 172. 
warning: Invalid argument supplied for foreach() in C:\home\user\public_html\drupal\themes\jolly\node.tpl.php on line 31. 

I am doing something wrong, or is this some kind of bug?

thanks,
abramo

Comments

fago’s picture

Status: Active » Fixed

no you are using the function wrong. have a look at it to see how the array is built or print it yourself by using print_r or dprint_r

abramo’s picture

@fago - many thanks for the clarification.
by merely replying to my query you are already giving me something, while you really owe me nothing - therefore my appreciation is for granted, no two ways about it.

however, there is an element of sadness in this:
your response assumes that I am a php programmer,
and if I am not, well, pity : I should have been, if I want to use this function.

so, if anybody kind enough finds the time just to tell me what I have to change in the above code to make it work, because I have not got the faintest?

thanks,
abramo

thanks,
abramo

abramo’s picture

Status: Fixed » Active
abramo’s picture

Category: bug » support
fago’s picture

Status: Active » Fixed

have a look at this issue:
http://drupal.org/node/87760

abramo’s picture

@fago : great : many thanks - this covers me completely :)
strange : this post did not come up when I did a search of past issues - maybe I have to learn to use Drupal search a bit better . . . .

I have a suggestion to make:
perhaps this code example

$children = nodefamily_relation_load_by_type($nid);

if (isset($children['your_content_type'])) {
  foreach ($children['your_content_type'] as $childnode)
    print node_view($childnode);
}

should go into the README for the module - it would save everybody a lot of unnecessary trouble.

thanks again,
abramo

fago’s picture

Title: Problem with load_by_type » explain load_node_by_type function better
Category: support » task
Status: Fixed » Active

yep, I agree this should be improved!

fago’s picture

Status: Active » Fixed

done & committed to all stable branches.

abramo’s picture

great :)

Anonymous’s picture

Status: Fixed » Closed (fixed)