Inluding a drupal module in a node
I'm fairly new to Drupal ... I've learned my way around a bit and hammered out one custom module so far. I was trying to figure out if there was a way to include or embed another module in a PHP-input-formatted node. In my case, I have a node with a couple of dynamically generated tables and I would like to include something like WebFM for file management on the same view. Is there a way 开发者_开发问答in drupal to do this sort of thing or am I totally heading down the wrong path? And if it's the latter, am I looking at creating another custom module to achieve what I'm looking for? I really just need something for users to be able to upload and view files (viewable only by that user) on the same page as some other user-specific information. WebFM might be more than I need and I would want to modify its look somewhat, but I thought I could make it work for my case. Thanks for any guidance.
its great you are making your own custom modules and so you are well on your way.
If I were you I would personally make what you are wanting to add to the page into a block, which you can place below or above the node. The block api is very powerful and flexible.
But if you are really wanting to place the contents into the node itself it is do-able but a lot more tricky. There is the node preprocess hook (MYMODULE_preprocess_node())which you can alter the contents that are fed to node, but by this point much of the node contents has already been grouped together so it is only really simple to add anything to the beginning or end of the node contents. But you can add other completely new variables in here to be used in your node.tpl.php as you please.
The other way is to make your own page based on a node using hook_menu. Here you can gather parameters in which to fire up the node using node_load($id), the node load function actually builds the node object of which it is very easy to manipulate the broken down node as you see fit. Then you can build your own page using this. But saying that if you have your own content type, you can make a template for that content type, and manipulate the data using preprocess_node but actually pass into your own data type based template the modified output of the node object which you get from node_load
I know there are many ways to tackle it, each with their own challenges. But Drupal is fairly flexible in allowing you easy access to such core data.
Hope it works out well....
The Filefield CCK module may be what you're looking for.
精彩评论