Skip to Content

Revision of Notes of the PHP from within Drupal 2nd session from Sun, 21/01/2007 - 2:02am

The revisions let you track differences between multiple versions of a post.

Manal's picture

Examples we used:

Example 1:

between the php tags:


$result = taxonomy_select_nodes( array(1, 3), 'or', 'all', true);
$html = node_title_list($result);
$html.= theme('pager');
print $html;

Example 2:

between the php tags:


$node = node_load(55);
$i=$_GET['choice'];
print $node->choice[$i]['chvotes'];

and add to the url:


?choice=1

Example 3:

between the php tags:


$node = node_load(55);
$i=arg(2);
print $node->choice[$i]['chvotes']."<br />";
print arg(0)."<br />";
print arg(1)."<br />";
print arg(2)."<br />";
print arg(3);

and add to the url:


/0

Functions that we used in the 2nd session:

Drupal functions:

  • taxonomy_select_nodes()
  • node_title_list()
  • theme()
  • theme_pager()
    • any drupal function that starts with theme_ is called a themeable function, i.e. it can be overridden in every theme folder (any theme can write its own html output for these variables, in our example it was the pager).
  • arg()

PHP functions:

  • array()

HTTP variables:

  • _GET
    • for getting data from the database
    • usually the URL changes, so that u can use the same URL to GET the same data (results) if used at other times.
  • _POST
    • for submitting/sending data to the database, e.g. in forms


Dr. Radut | blog