is there a way to find the ID of the Node that was last put on the frontpage?

doing a sql select on the highest node number does not work, since some nodes are not promoted to frontpage

also:
we write articles and save them in moderation (without putting them on frontpage)
then some other articles come in, and we publish what we feel like that needs to be published at that time

-> so sometimes newer articles are published earlier than some articles that are in moderation queue for a longer amount of time

so this is a small problem to think about

Comments

techczech’s picture

Sounds like you may want to use Views and Nodequeue to manage that sort of thing.

______________________
Dominik Lukes
http://www.dominiklukes.net
http://www.hermeneuticheretic.net
http://www.czechupdate.com
http://www.techwillow.com

jorre’s picture

Not really...

I'm just looking for let's say an SQL statement that knows what node is put on the frontpage most recently

Pakfriet.be
Uzegt.be

nevets’s picture

It sound like you want to know the most recently promoted node to the front page that is ready for display. In this case this should work

$sql = "SELECT nid FROM {node} WHERE";
$sql .= " status = 1";   // Node is ok to display
$sql .= " AND promote = 1";   // Node is promoted to the front page
$sql .= " AND moderate = 0";  // Note sure this one is needed, it says node is not in moderation
$sql .= " ORDER BY changed DESC";   //  Show the most recently modified node first

$results = db_query_range($sql, 0, 1);  // Get the most recent node
$data = db_fetch_object($results);

if ( $data->nid ) {
  // Have a the nid of the most recently published node to the front page
}

Notes:
1) You do not need it on the multiple lines, I wrote it that way to make it easier to comment.
2) I don't think status can be 1 with moderate not equal to 0 but may be wrong about that, hence the check for moderate
3) This assumes all the code that plays with the flags updates 'changed' when changing flag values (status, promote, moderate)

jorre’s picture

Hi nevets,

This is something I also thought about, but imagine this:

I have 10 articles on my frontpage (newest one on top has ID 10, lowest one has 1)
What if I change something to article number 5 (let's say I retype a misspelled word there, and save it again)

Does the changed date change then? Or is this the date that is posted under "author information"... ? And it doesn't change, unless I manually change it?

Pakfriet.be
Uzegt.be

nevets’s picture

That would also change the "changed" timestamp and if that is a problem then I would write a small module that tracks the last node promoted to the front page. Pretty straight forward unless one can unpromote a node from the front page before having promoted a new one.

feeper’s picture

That is funny

I just found that and implemented it. Now I have a discrepancy.

*Message from the ....

*Reminder of ....

*CAJ urges ....

*National Conference....

These are the first three articles.

Now my pager is acting up, because it does not appear to be keeping order. If I click on next on the most recent article....Reminder of... appears. If I click on the next link it then jumps past CAJ urges... to the next article - National Conference.

Here is my pager code in my template.php file:

function kd_pager($tags = array(), $limit = 1, $element = 0, $parameters = array()) {
  global $pager_total;
  $output = '';

  if ($pager_total[$element] > 1) {
    $output .= '<div class="pager">';
    $output .= theme('pager_first', ($tags[0] ? $tags[0] : t('')), $limit, $element, $parameters);
    $output .= theme('pager_previous', ($tags[1] ? $tags[1] : t('< Previous ')), $limit, $element, 1, $parameters);
	$output .= theme('pager_next', ($tags[3] ? $tags[3] : t(' | Next >')), $limit, $element, 1, $parameters);
    $output .= theme('pager_last', ($tags[4] ? $tags[4] : t('')), $limit, $element, $parameters);
    $output .= '</div>';

    return $output;
  }
}

I set the limit to '1' from '10'....but now that I think of it - that wouldn't do anything here because I am not showing next page / previous page....just next and previous articles.

Did I do this right?