Community & Support

Views 'new content since you last logged in'

Hi all,

Been racking my brain on this one for a while. Hopefully someone can help :-)

In Views 2 is it possible to create a view that would display the following:

'There are (x) new items since you last logged in'

Where the above references the number of new nodes published since an individual user logged in and (x) is a link through to a list of the aforementioned nodes.

Any help would be greatly appreciated!

Thanks

Steve

Comments

This might be a little

This might be a little roundabout but it should work fine...

Add a filter that is Node: has new content
Add some sort of field

Put this in your header/footer:

<?php
$view
= views_get_current_view();

// execute view query
$view->execute();

// results are now stored as an array in $view->result
$count = count( $view->result );

print
"There are $count new items since you last logged in";
?>

Not roundabout at all, worked

Not roundabout at all, worked like a charm! Thanks Alan.

Just a quick question. Is there a way you know of to make $count a link to a list of new content?

Steve

http://stephenwilsondesign.co.uk

Based in Leeds, United Kingdom, I'm an experienced web and graphic designer with a passion for all things open source (especially Drupal).

Print out some good old html

First create the list of new content using a view. The same Node: new content filter should be fine, along with Node: title and (trimmed?) Node: body fields. Make a page display, and give it a path.

Then, you should be able to just add html around your php. For example:

There are <a href="path">
<?php
$view
= views_get_current_view();
// execute view query
$view->execute();
// results are now stored as an array in $view->result
$count = count( $view->result );
print
"$count ";
?>

pages</a> with new content.

I took the rest of the text besides the $count out of the php print statement. The anchor tag <a> surrounds the php and the word "pages", so that would appear as the link.

Alan

Excellent, thank you very

Excellent, thank you very much Alan.

Steve

http://stephenwilsondesign.co.uk

Based in Leeds, United Kingdom, I'm an experienced web and graphic designer with a passion for all things open source (especially Drupal).