It almost frustrated me until I came up with the following code that works:
<?php
$query = db_select('node', 'n');
$nids = $query
->fields('n', array('nid'))
->orderBy('created', 'DESC')
->range(0, 7)
->execute()
->fetchCol('title');
$nodes = node_load_multiple($nids);
echo '<ul class="menu">';
foreach ($nodes as $recentNode) {
echo '<li class="first"><a href="?q='.drupal_lookup_path('alias',"node/".$recentNode->nid).'">'.$recentNode->title.'</a></li>';
}
echo '</ul>';
?>
$query = db_select('node', 'n');
$nids = $query
->fields('n', array('nid'))
->orderBy('created', 'DESC')
->range(0, 7)
->execute()
->fetchCol('title');
$nodes = node_load_multiple($nids);
echo '<ul class="menu">';
foreach ($nodes as $recentNode) {
echo '<li class="first"><a href="?q='.drupal_lookup_path('alias',"node/".$recentNode->nid).'">'.$recentNode->title.'</a></li>';
}
echo '</ul>';
?>
No comments:
Post a Comment