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

  • SEARCH
  • Home
  • 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 8606545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:07:03+00:00 2026-06-12T03:07:03+00:00

In Drupal 7 i want to add node to a another node when the

  • 0

In Drupal 7 i want to add node to a another node when the user is loged.

I am using Drupal 7, and I want to add a node inside another node when the user is logged in :

function my_modul_node_view($node, $view_mode, $langcode) {
    global $user;
    switch ($node->vid) {
    case 4:
        $node2 = node_load(37);
        if ($user->uid > 0) {
            $node->content['my_data_field'] = array(
                '#markup' => drupal_render($node2),
                '#weight' => 10,
            );   
        }
    } 
}

I am getting the following error message :

Fatal error: Cannot use object of type stdClass as array

I am using the following form :

    $form = drupal_get_form('user_login', $node);
    $node->content['data_collection_form'] = array(
        '#markup' => drupal_render($form),
        '#weight' => 10,
    );

What is the proper way to do this in my module?

  • 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-06-12T03:07:04+00:00Added an answer on June 12, 2026 at 3:07 am

    You just need to make one small change as far as I can tell:

    $node->content['my_data_field'] = array(
      '#markup' => drupal_render(node_view($node)),
      '#weight' => 10,
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want add the Site Wide user form a node. I used Drupal 7
I want to develop a module that add fields to user profile in drupal
I want to add a note on a Redmine issue. I am using Drupal
i'm using WYSIWYG module to implement FCKeditor in drupal. If i want to add
i am using drupal 7. I want to add forums in OG groups so
I want to add menu at footer in Drupal. (e.g. contact us | sitemap
I created a site using drupal 6.I want to show primary menu items only
I want to disable a cck field inside a specific form in Drupal 6.
I want to add a custom search option on my drupal theme in a
I want to add an email field to submit new comment form in Drupal

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.