PHP front_page help, real simple: disply content of one specific node

freehunter - July 27, 2006 - 02:56

Okay, this has got to be real simple, I just don't know PHP well enough to do it. I am using the front page module, and I want to display content from one specific node (two actually, but I can duplicate the code to show both of them easily enough, right?). I want to display a message of the day type thing, site notices, that kind of thing, which is on node 21 or something like that (site.com/notice is the easy link), and the welcome message, which is on mode 22 (site.com/welcome_message). Simple, just display the full content of two node (note, not the teaser, but full content, if possible)

The two functions you need are node_load and node_view

nevets - July 27, 2006 - 03:22

To get the output of a single node you need something like this

$nid = 21;
$node = node_load($nid);
$output = node_view($node, FALSE, FALSE, FALSE);  // Change the last one to TRUE if you want the links for the node

You can read more about node_view and it's arguments at: http://api.drupal.org/api/4.7/function/node_view

That code generates a blank

freehunter - July 27, 2006 - 04:57

That code generates a blank page for me, and I don't know a lick of how to code PHP. I can usually peice things together based on my previous experiences with programming (I know a language or two), but PHP always has thrown me. I appreciate the help, it is more than I usually get, but I need a working code.

substitute '21' for the

dman - July 27, 2006 - 06:05
  1. substitute '21' for the node id you want.
  2. print $output;
  3. Set input type to 'PHP code'

.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/

 
 

Drupal is a registered trademark of Dries Buytaert.