This forum is for module development and code related questions, not general module support. For general support, use the Post installation forum.

Accessing Current Node in Block Module

Ok, I am quite new to drupal, so please forgive me if I am missing something elementary. However, I am looking through module source code, the API docs, and this forum, and still haven't found an answer to my problem.

I want to create a module that will produce context-sensitive content in a block in the right-hand column. I am using a taxonomy to assign each node to a content hierarchy. For each node, then, I want to produce sidebar content that is related to it through the taxonomy terms. I would like to configure this like other blocks -- i.e., enable the module, enable the block, and tell it to go on the right.

As far as I can tell, I need to get the current node object to get its terms. But, I can't figure out how to identify the current node without having to parse the URL, and I can't help but think that that seems like a hack. Is this really the best/only way? I have read through a number of other forum posts that express the same sorts of issues, but the solutions all divert from the original intent. My apologies if, in my travels, I simply haven't found the one, true post that contains my answer -- if you know where it is, please let me know!

My compromise right now is to not treat it like other blocks. In my template code, I am just making a call to:

<?php 

// the context-sensitive stuff
print mysidebar_display($node);

// the normal sidebar
print $sidebar_right;

?>

This seems less comfortable to me, but it will work for now. Unfortunately, I cannot intersperse the context-sensitive block within the other sidebar (what if I want it in the middle of the other blocks?). Why is $node not in scope for a module?

-Josh-

flexinode - a simple concept of how to make it more scalable

I like and am challenged by flexinode for all the usual reasons, but have found the following approach useful in solving the database overhead of flexinode that can make it too resource intensive in some circumstances. The basic concept is to 'compile' the flexinode content into the body and abstract in the node table values and only load the flexinode table values when necessary.

Teaser and Body Templates for CCK

In the latest Drupal Podcast, JonBob and I talked about CCK. One of the things that we talked about were the problems getting the CCK field information to display nicely on pages and particularly in RSS feeds. We talked about creating a forum topic so that people could give some feedback on this subject. Here it is!

possible audio module bug?

I installed audio module in drupal 4.7 and it works fine in Firefox, but in Internet Explorer the little flash player does not appear. Thus only giving the option to download the audio file. The site is at http://hhbc.crickster.com

Modify user data on the fly

I need to modify information in the user profile based on a cookie that is set when the user visits a certain page. I'd like to be able to do this like so:

Example:

if($_COOKIE['foo']) {
     $user->profile_foo=1;
     user_save($user);
}

Will this work? It's not clear to me from the documentation how to update user data outside of the standard user edit forms....

Views adaptation for non-nodes

I'm attempting to adapt the views module for non-nodes. Is this something that should even be attempted? Has anyone tried this?

I started by commenting out calls to db_rewrite_sql and looking at the _views_query->query() method.

Any leads would be helpful.

-Ray

Pages

Subscribe with RSS Subscribe to RSS - Module development and code questions