/[drupal]/contributions/modules/helpers/helpers_node.module
ViewVC logotype

Contents of /contributions/modules/helpers/helpers_node.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Wed Feb 21 10:32:37 2007 UTC (2 years, 9 months ago) by ber
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-5, DRUPAL-4-7
File MIME type: text/x-php
Adding helpers_node.module to the helpers. Contains all the node specific helpers.
Introduced one new function: node_load_current() to load current active node.
Moved is_node_page to helpers_node.module
1 <?php
2 // $Id$
3
4 /**
5 * @file
6 * This is a library of useful node functions and methods.
7 * please insert the link if you have a patch for core to introduce a function from this lib to core.
8 */
9
10 /**
11 * Implementation of hook_help().
12 */
13 function helpers_node_help($section) {
14 switch ($section) {
15 case 'admin/modules#description':
16 return t('A development library for nodes. Contains useful functions and methods for node manipulation and node queries.');
17 }
18 }
19
20 /**
21 * Find out if the current page is a node page.
22 * @return TRUE if the page is a node, FALSE if it is another page.
23 */
24 function is_node_page() {
25 if (arg(0) == 'node' && is_numeric(arg(1))) {
26 return TRUE;
27 }
28 return FALSE;
29 }
30
31 /**
32 * Grab the current 'active' node
33 * An active node is the one node 123 as shown on page with path node/123, or
34 * its aliased path(s).
35 * @return $node object if the page is a node, empty $node object if it is not a
36 * node, or if we cannot see it, for any valid reason.
37 */
38 function node_load_current() {
39 $node = new stdClass();
40
41 if (is_node_page()) {
42 $node = node_load(arg(1));
43 }
44
45 return $node;
46 }

  ViewVC Help
Powered by ViewVC 1.1.2