Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6850019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:04:22+00:00 2026-05-27T01:04:22+00:00

I have an array of node IDs with which loop through and run node_load($nid)

  • 0

I have an array of node IDs with which loop through and run node_load($nid) to retrieve the data for each of those nodes. Take for example the below code- that’s roughly how it works at the moment.

foreach( $node->field_flights['und'] as $flight ):
    $flightNode = node_load($flight['nid']);

    echo $flightNode->title;

What I want to achieve is to load the node, then be able to do something along the lines of echo render($flightNode); so that it loads the template file for that node and I can render the $title_suffix variable in the node template which has been loaded.

I’ve tried the following to no avail. Nothing is output at all.

$flightNode = node_load($flight['nid']);
$builtFlightNode = node_build_content( $flightNode );
echo render( $builtFlightNode );

Would anyone provide some insight?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:04:23+00:00Added an answer on May 27, 2026 at 1:04 am

    You can use node_view() to prepare the render array. For performance it might be wise to consider using node_load_multiple() (and it’s counterpart node_view_multiple()) like this:

    $nids = array();
    foreach($node->field_flights['und'] as $flight):
      $nids[] = $flight['nid'];
    endforeach;
    
    $flight_nodes = node_load_multiple($nids);
    
    $view_mode = 'teaser'; // could also be 'full'
    $views = node_view_multiple($flight_nodes, $view_mode);
    
    // Renders all nodes in one go
    echo render($views);
    

    If that doesn’t fit in with what you’re doing though this should work on a node by node basis:

    foreach($node->field_flights['und'] as $flight):
      $flight_node = node_load($flight['nid']);
      $view = node_view($flight_node, $view_mode);
      echo render($view);
    endforeach;
    

    If you need to modify the content before it’s rendered, you can just step through the $views or $view arrays and change what you need to before running it through render(). If you just want a particular part of the node content rendered, again just step through the array and apply render to the particular sub-array you’re interested in.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

INFO: I have an Array of 100 nodes, [ 0 .. 99 ]. Each
I have two arrays, one is a node-node-cost array [a_node,b_node,cost] which has 8000 entries
Say you have the following array: $nodes = array( parent node, parent node, array(
I have an array of a few million numbers. double* const data = new
In the Kademlia protocol node IDs are 160 bit numbers. Nodes are stored in
I have a documentFragment with several child nodes containing some .data() added like so:
Hello i have this method: private function findConnectedNodes(node:Node):Array{ var test_node:Node; var surrounding_nodes:Array = [];
So I am quite confused. I have a public string() array defined, and each
I have an array like the following: people = [{'node': 'john', 'dist': 3}, {'node':
I have an array ( nodes[][] ) that contains values of effective distances that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.