All pastes #977280 Raw Edit

Someone

public text v1 · immutable
·published 2008-04-08 18:58 UTC
rendered paste body
function hotnewthings(){
/*****
 *  look for page args 
*/

$list_qty = 4;
$sql = "SELECT n.nid, n.created 
FROM node AS n
INNER JOIN node_revisions AS r ON r.vid = n.vid
WHERE n.type = 'products'
ORDER BY n.created DESC ";
      
$result = db_query_range(db_rewrite_sql($sql), 0, $list_qty);
$output = "";
$content = "";
while ($anode = db_fetch_object($result)) {
  // print your markup here
  $output .= node_view(node_load($anode->nid), TRUE);
  //print check_markup($anode->body, $anode->format, false);
}

$content .= "<h3 class=\"postenote\">Hot new things</h3>";
$content .= "<div class=\"products-list\">";
$content .= $output;
$content .= "</div>";
$sql2 = "SELECT n.nid, n.vid, n.type, n.created, r.body, r.format 
FROM node AS n
INNER JOIN node_revisions AS r ON r.vid = n.vid
WHERE n.type = 'event'
ORDER BY n.created DESC ";
      
//$result = db_query($sql);
$result2 = db_query_range(db_rewrite_sql($sql2), 0, $list_qty);
$output2 = "";
while ($node = db_fetch_object($result2)) {
  // print your markup here
  //$output .= node_view(node_load($anode->nid), TRUE);
  $output2 .=  check_markup($node->body, $node->format, false);
}
$content .= "<h3 class=\"postenote\">What's new, hot and on this week?</h3>";
$content .= "<div class=\"events-list\">";
$content .= $output2;
$content .= "</div>";
return $content;
}

function new_things_menu() {

  $items = array();

  //this was created earlier in tutorial 7.
  /*
  $items[] = array(
    'path' => 'admin/settings/newthings',
    'title' => t('On this date module settings'),
    'callback' => 'drupal_get_form',
    'callback arguments' => 'onthisdate_admin',
    'access' => user_access('access administration pages'),
    'type' => MENU_NORMAL_ITEM,
   );
  */
  //this is added for this current tutorial.
  $items[] = array(
    'path' => 'hotnewthings',
    'title' => t('Hot New Things'),
    'callback' => 'hotnewthings',
    'access' => user_access('access content'),
    'type' => MENU_CALLBACK
  );

  return $items;
}