Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > Count Articles published after user last login View modes: 
User avatar
Member
Member
neeraj.jain-aonhewitt - 2/2/2012 12:22:23 AM
   
Count Articles published after user last login
Hi,

I want to show a facebook like notification for no. of articles added/published after user's last login date. So every time a user logs into the site he/she will get to see a number on the menu/top bar indicating new articles published after the last login date/time.
How can i achieve this functionality ?

Thanks
Neeraj

User avatar
Kentico Support
Kentico Support
kentico_janh - 2/2/2012 7:09:39 AM
   
RE:Count Articles published after user last login
Hello,

You would need to create your own custom web part for this, in which you will select all documents from your site (e.g. through the GetDocuments function), which was added after a current user's last login (where condition in the GetDocuments function). And then you will just display the number of returned rows.

Best regards,
Jan Hermann

User avatar
Member
Member
neeraj.jain-aonhewitt - 2/2/2012 7:17:13 AM
   
RE:Count Articles published after user last login
Thanks for the guidance,

Can you give/share some sample code for the same. And also i want to count the no. of Articles based on its Published Date, ie all the articles where PublishFrom < LastLoginDate and PublishTo > LastLoginDate.

Please also clarify, if i add some new attributes to DocumentType(Article in my case), then how can i access them from code behind to use them in Where condition in my custom webpart.

Thanks
Neeraj

User avatar
Kentico Support
Kentico Support
kentico_janh - 2/6/2012 3:28:12 AM
   
RE:Count Articles published after user last login
Hello,

Sure, for a creation of that where condition, you will need to remember or store somewhere an information about the date of a last login. This information is stored in a database and it is accessible through the CMSContext.CurrentUser.LastLogon variable, but this date is overwritten by actual DateTime after your user has logged in, so you need to store this value before it is changed. So now you just need to select Articles, which fulfil that condition:

DataSet ds = TreeHelper.GetDocuments(CMSContext.CurrentSiteName, "/%", CMSContext.CurrentDocumentCulture.CultureCode, true, "CMS.Article", your_where_condition, "", -1, true, 0);


All you need is to count the number of documents in the returned dataset.

Best regards,
Jan Hermann