Skip to Content

Notes of the PHP from within Drupal 2nd session

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

try 0 and 2 instead of one, to get the number of votes for the first and third choice respectively.

Example 3:

Doing the same thing but using Drupal functions.

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 we learned:

PHP functions:

HTTP variables:



Dr. Radut | blog