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 6161959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:34:12+00:00 2026-05-23T21:34:12+00:00

I writing a module for Drupal 7. It must get current $node variable in

  • 0

I writing a module for Drupal 7. It must get current $node variable in one function, e.g. hook_init() or similar, and this variable should be accessible from another function. I found discussion about node_load(arg(1)) and the author of solution said that performance is no concern because of caching.

So, should I call node_load() in every function I need not being afraid of performance issues of are there any other ways to pass variables between module functions?

To be more exact: I’ve placed a block with module on pages with a certain node types and in hook_block_view function I need to access to current node object. I’m succeeded using node_load so far. But maybe there is a better way.

Thanks in advance!

  • 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-23T21:34:15+00:00Added an answer on May 23, 2026 at 9:34 pm

    In drupal 7 node_load() calls entity_load(), which caches the results, so if you call node_load() twice, it will be returned from cache.

    Using node_load() is better solution than passing global variables between modules, especially if you use some third-party caching modules (APC, memcached or other). If you care about performance just try to use one of these modules (I prefer memcached).

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

Sidebar

Related Questions

Preface: Yes, I've read: http://drupal.org/node/547518 I am writing 'foo' module for Drupal6, where I
I'm writing a Drupal module and have run into what should be a trivial
I'm writing a global error handling module for one of my applications. One of
I am writing a drupal module that involves a form with many checkboxes. E.g.
I'm writing a Drupal module that deals with creating new nodes from CSV files.
I'm writing a drupal module, and I need to write a query that returns
I am writing a Drupal module where users send down content (formatted as HTML).
Hey guys, here is my problem. I am writing a Drupal module. A user
I made a private section on a drupal site by writing a module that
I'm writing this in the forlorn hope that someone has already done something similar.

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.