Is anyone using this in Drupal 5x? I can't seem to get it to work.

http://drupal.org/node/23230

<?php
/**
* the following displays a list of the 10 most recent weblog titles
* and links to the full weblogs of a certain user.
* If you want to increase/reduce
* the number of titles displayed..simply change the $listlength value
*
* for a different user change the $userid value
*
* works with drupal 4.6.
*
*/
$listlength="10";
$userid="8";

$output = node_title_list(db_query_range(db_rewrite_sql("SELECT n.nid, n.title, n.created FROM {node} n WHERE n.type = 'blog' AND n.uid = $userid AND n.status = 1 ORDER BY n.created DESC"), 0, $listlength));
print $output;
?>

Thanks

Comments

johsw’s picture

1: where did you put the code?
2: what does it do? (does it print anything?)

phopkins’s picture

Josh,

I put the code in my root index file:

http://www.uchuskies.com/

I installed drupal at http://www.uchuskies.com/drupal

The error I get is:

Fatal error: Call to undefined function: node_title_list() in /home/content/h/o/p/hopkinspat/html/index.php on line 59

Thanks for your help.

Patrick

papile’s picture

Nothing should go in your root index.php file. Did you put this before drupal_bootstrap? Also you should use module_invoke(node,title_list); But dont put stuff in your index.php. If you explain exactly what you want to accomplish, I can give you a better way of doing it.

papile’s picture

Ok I see what you want to do. Look up how to make a block with the block example on api.drupal.org. There you will be able to make this into a block, style it, and display it on your page. Also, just a plain db_query will work. You dont need db_rewritesql

phopkins’s picture

Thanks for the responses Papile.

What I was trying to do was get the most recent blog posts on my home page. Is that possible?

Thanks.