Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By rjung on
Does anyone know of a hack/patch to allow Drupal to display links for the next/previous blog entries from a user? I'm looking into how to implement such a feature, but I'd rather not re-invent the wheel if I don't have to.
Thanks,
Comments
Here's a solution
Okay, for any other folks who are interested in this functionality, this code will do the trick. Just stick the function into blog.module and you're good to go:
--R.J.
http://www.electric-escape.net/
--R.J.
cheers R.J for the code
cheers R.J for the code looks similar to that in the book module
do you know what
$result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title FROM {node} n WHERE n.type = 'blog' AND n.uid = %d AND n.status = 1 AND n.created < %d ORDER BY n.created DESC"), $node->uid, $node->created, 0, 1);
does or shall i say the ,0,1) on the end
I'll play around with it tomorrow after work have tried subing in
$query = "SELECT n.nid, n.created FROM {node} n INNER JOIN term_node ON n.nid = term_node.nid WHERE n.type = '$node_type' AND term_node.tid = $taxo_id AND n.status = 1 ORDER BY n.created ASC";
$results1 = db_query_range(db_rewrite_sql($query), $instancePos, 1);
but not having any luck listing a blog
db_query_range()
The ", 0, 1)" at the end of the db_query_range() means you just want to fetch the first result from the query. The query already returns results earlier than the date given, sorted in descending order ("n.created < %d ORDER BY n.created DESC"), and the "0, 1" limits it to one previous entry by timestamp. So the call will fetch just one entry that's earlier than the date of the current entry -- which means the previous (by date) node.
You can get documentation for db_query_range() here.
As for your code snippet not working, perhaps the single-quotes around "$node_type" are preventing it from being substituted. Maybe you can try using string concatenation instead:
I'm not a SQL expert, but it's worth a quick test.
--R.J.
http://www.electric-escape.net/
--R.J.
Does this work for
Does this work for 6.x?
Drupal core needs to have this simple but necessary function for blog nodes!
forget what i said...
forget what i said... http://drupal.org/project/custom_pagers
never mind.
never mind. http://drupal.org/project/custom_pagers