I have created a function to go in template.tpl.php which generates a dropdown box, showing you the latest posts from a particular content type. The amount of items is variable, and you can restrain the number of characters of the titles so your layout will not change when a large title is entered. This is useful is you want to provide a clean and easy way for your visitors to access your nodes.
First I came up with this function to shorten the $title in a nice way:
// Function for cutting the parsed blogitems:
function wordCut($text, $limit, $end) {
if (strlen($text) > $limit) {
$txt1 = wordwrap($text, $limit, '[cut]');
$txt2 = explode('[cut]', $txt1);
$ourTxt = $txt2[0];
$finalTxt = $ourTxt.$end;
} else {
$finalTxt = $text;
}
return $finalTxt;
};
So now I can call wordCut() when I want to shorten a var displayed by my theme. Next thing to do is let the function render my selectbox, with the amount of options I want to display. When you select a title and release the mousebutton, Drupal will direct you to that particular $node_url, useful for displaying on the homepage.