I am new at programming Drupal. I am trying to create a module that display the users nodes.
If I am going at it the wrong way, let me know.
Here is my displaynode.info file:
; $Id$
name = "displaynode"
description = "Display nodes created by user"
;dependencies[] =
core = 6.x
Here is my "displaynode.module" file:
<?php
// $Id$
/**
* Implementation of hook_perm().
*/
function displaynode_perm() {
return array('view displaynode');
}
/**
* Implementation of hook_menu().
*/
function displaynode_menu() {
$items['admin/settings/displaynode'] = array(
'title' => 'displaynode',
'description' => 'Display the user node',
'page callback' => 'drupal_get_form',
'page arguments' => array('displaynode_nodeapi') ,
'access arguments' => array('administer site configuration'),
'type' => MENU_CALLBACK,
);
return $items;
}
/**
* Implementation of hook_nodeapi().
*/
function displaynode_nodeapi() {
global $user;
switch ($op) {
case 'view':
// query to execute
$sql = "select nid from node where uid = %d";
$result = db_query($sql, $user->uid);
$output = "";
while ($node = db_fetch_object($result)) {
$output .= node_view(node_load($node->nid), true);
}
break;
}
print $output;
}
When I go to "admin/settings/displaynode", all I get is the "admin/settings" page.
Can some one give me an idea of what am I missing?
:-)

Comments
Why not use Views for this
Why not use Views for this simple feature?
--
Christoph Weber
Christoph, I do not know how
Christoph,
I do not know how to do that but in the long run I wanted to create my second module to learn more of how to mess with the code and NOW, I am able to display the last 5 nodes
for the user but it does not display within the Drupal frame.
I am missing:
1) How to display the result within the Drupal frame
function displaynode_page() {
global $user;
$sql = "select nid from node where uid = %d AND status=1 ORDER BY created DESC";
$result = pager_query(db_rewrite_sql($sql, $user->uid), variable_get('default_nodes_main', 5));
while ($node = db_fetch_object($result)) {
$output .= node_view(node_load(array('nid' =>$node->nid)), true);
}
// THIS DISPLAYS THE NODEs but it take the entire pages real estate
// and I do not get the left or right columns
print $output;
//IF I DO THIS IT KEEPS ASKING TO LOGIN, OVER AND OVER....
// $header = array("Display nodes for " . $user->name);
//$link_to_front = "<front>";
//return theme_table($header, $output).'<br/>'.$link_to_front;
// IF I DO THIS I GET A BLANK SCREEN
//return theme($output);
}
Thanks,
OK, I found out that I wanted
OK, I found out that I wanted to do, "eafarris" has already done. His code is similar
to what I wanted to do but he was doing it better.
If you are interested see:
http://drupalcode.org/viewvc/drupal/contributions/sandbox/eafarris/unpub...
and http://drupal.org/node/10611?mode=2&sort=2 down to #18
TNKS (moving to my next thing ;-] )