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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:24:36+00:00 2026-05-17T02:24:36+00:00

I have created a custom module and am using hook_block to programmatically create some

  • 0

I have created a custom module and am using hook_block to programmatically create some blocks.

My question is how can I access field values including CCK fields for the current node within my module?

I basically want to get a value from a CCK field and use the value when building my block for that page.

  • 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-17T02:24:36+00:00Added an answer on May 17, 2026 at 2:24 am

    Getting at the current node is an awkward pain in the posterior. Standard practice is to do something like this:

    if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == '') {
      $node = node_load(arg(1));
      // Collect output.
    }
    

    arg() pulls elements out of the Drupal path. Since all nodes (regardless of what a path alias might show you) appears at node/#, by checking for ‘node’ and that the second element is a number, you are fairly well guaranteed to have your hands on a node. Checking the third path element allows you to avoid processing on the node edit form and other pages that hang off a specific node.

    CCK Values are loaded into the node, and usually look something like this:

    // Text field. Structure also works for number fields.
    $text = $node->field_my_text_field[0]['value']
    // Node Reference field.
    $nref = $node->field_my_nref_field[0]['nid']
    // User Reference field.
    $uref = $node->field_my_uref_field[0]['uid']
    

    The “0” array element specifies the delta of the field. Any given field can actually process multiple values, and the array structure in CCK assumes this possibility even if you restrict the field to a single value.

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

Sidebar

Related Questions

I am using apachesolr module in drupal I have created a custom facet field
I'm trying to create a custom module using Magento's EAV structure and have been
I am trying to create a custom table using custom module. I have been
I created a custom module for Orchard following this wonderful guide . I have
I've created a custom module citation for academic references. Citations have, among other things,
I have a module in which I created a custom page with controller and
friends, i have created custom title bar using following titlebar.xml file with code <?xml
I am using Symfony 1.4.8 and Propel as ORM. I have created a custom
I have a custom c++ module for python that exposes functions, some of which
I'm using google app engine/python. And I have created a custom datatype and property.

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.