After Viewing Last Node, then the items should not be displayed again
rdilauro - August 6, 2008 - 15:47
| Project: | Last Node |
| Version: | 6.x-2.3 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | TheCrow |
| Status: | active |
Jump to:
Description
Looking to see that after you use Last Node, the next time you use it, could it ONLY display items that were changed since your last visit?

#1
Into last_node.module, function lastnode_display :
Substitute this line:
<?php...
$result = db_query_range("SELECT n.title, n.nid, n.created FROM {node} n WHERE n.status = 1 AND n.type = '%s' ORDER BY n.created DESC", $node_type, 0, $numitem);
...
?>
with:
<?php
...
global $user;
if ($u = (int) $user->uid > 0) {
$result = db_query_range("SELECT n.title, n.nid, n.created, h.timestamp, n.changed FROM {node} n LEFT JOIN history h ON n.nid = h.nid AND h.uid = %d WHERE n.status =1 AND n.type = '%s' AND (h.timestamp IS NULL OR h.timestamp < n.changed) ORDER BY n.created DESC", $user->uid ,$node_type, 0, $numitem);
}
else {
$result = db_query_range("SELECT n.title, n.nid, n.created FROM {node} n WHERE n.status = 1 AND n.type = '%s' ORDER BY n.created DESC", $node_type, 0, $numitem);
}
...
?>
AND in the same file, function _last_node_page:
this line:
<?php...
$result = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = '%s' AND n.status = 1 ORDER BY n.created DESC"), variable_get('default_nodes_main', 10), 0, NULL, $type);
...
?>
with:
<?php
...
global $user;
if ($u = (int) $user->uid > 0) {
$result = pager_query(db_rewrite_sql("SELECT n.title, n.nid, n.created, h.timestamp, n.changed FROM {node} n LEFT JOIN history h ON n.nid = h.nid AND h.uid = %d WHERE n.status =1 AND n.type = '%s' AND (h.timestamp IS NULL OR h.timestamp < n.changed) ORDER BY n.created DESC"), variable_get('default_nodes_main', 10), 0, NULL, $user->uid, $type);
}
else {
$result = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = '%s' AND n.status = 1 ORDER BY n.created DESC"), variable_get('default_nodes_main', 10), 0, NULL, $type);
}
...
?>
P.S. : put the whole query string in the same line