Small frontpage workaround
Last modified: August 23, 2009 - 22:32
hi !
I didn't like how drupal show the 'promoted to frontpage' nodes, so I've hidden them and then re-writed
I want to share this tips so maybe someone can help me to find better solution
1)create a really empty page
title: a whitespace, 1 char
body:
<?php
return;
?>2) in settings set this page as homepage
now in template page.tpl.php (using the bluemarine template, PHPtemplate engine)
force the correct check of the frontpage ($is_front variable)
<?php
//this is valid for node/*,
$def_fp=variable_get('site_frontpage',NULL);
if(($is_front or (arg(0)=='node' && $def_fp==arg(1)) ))
$is_front=1;
else
$is_front=0;
?>3) create a new block in content zone for nodes promoted in homepage (promote=1):
<?php
// n. of nodes
$limit=5;
$res=db_query("SELECT n.nid FROM {node} n WHERE n.status = 1 AND n.promote = 1 ORDER BY n.changed DESC limit $limit");
while($node = db_fetch_object($res)){
$n=node_load($node);
echo theme('node',$n, $teaser = TRUE, $page = FALSE);
}
?>same work, but to see the nodes in a category
<div class="frontpage-item"><?php
// n. of nodes
$limit=3;
//taxonomy term id (/taxonomy/term/*)
$term_id=16;
$res=db_query("SELECT n.nid FROM {node} n INNER JOIN term_node ON n.nid = term_node.nid WHERE term_node.tid = $term_id AND n.status = 1 and n.promote=0 ORDER BY n.created DESC limit $limit");
while($node = db_fetch_object($res)){
$n=node_load($node);
echo theme('node',$n, $teaser = TRUE, $page = FALSE);
}
?></div>et voilà, to check how it works look at http://www.informatoreuropeo.eu
let me know what you think about ths solution !
bye,
luca

In 5.x and above
Note that this is marked for 4.7. With 5.x and above you can use a view to accomplish the same thing without programming.
1. Create a view. Mark it as available in a block.
2. In Admin/blocks, the new view will show up as a block. Select "Content" as the region.
Voila, you have the same thing as above. If you don't want the block in Content but in some other region that you specify, make your own region: http://drupal.org/node/65064.
Tip: It's sometimes handy to debug views in a page before mucking around with blocks. Just check "page" in the view and assign the view a URL.
Andre'