Portal Engine
Version 3.x > Portal Engine > Obtain document's last modified date View modes: 
User avatar
Member
Member
gary.chan-e-crusade - 8/26/2008 7:10:43 AM
   
Obtain document's last modified date
Hi,

Would you please give me direction on how to obtain a document's (in my case its either menu item or file, but solution should be applicable to any doc type) last modified date when working with a Repeater, DataList as well as Full Text Search?

Another related question, what if I have following structure

Menu Item Parent
-- Menu item 1
---- Child 1A, 12/08/2008
---- Child 1B, 25/08/2008
-- Menu item 2
---- Child 2A, 11/07/2008

And I place a Repeater webpart in Menu Item Parent, listing Menu Item 1 & 2, just like the demo Corporate site, Images.aspx page. Beside showing the document name and teaser image, also display number of children they have as well as the most recent modified date among these children? Something like:

Menu Item 1 (Teaser image)
Contains 2 items
Last modified: 25/08/2008

Menu Item 2 (Teaser image)
Contains 1 item
Last modified: 11/07/2008


Thanks and Best Regards,
Gary

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 8/28/2008 5:49:59 AM
   
RE:Obtain document's last modified date
Hi Gary,

You need to change the transformation you are using in this repeater for displaying the list. In the transformations (in general), you can easily use any column name frm the DB view "View_CMS_Tree_Joined". For example in your case: <%# Eval("DocumentModifiedWhen") %> for the modification date and <%# Eval("NodeChildNodesCount") %> for the number of child items.

You can also add another columns to this view to handle them in this way, or you can also create a custom function to the transformations - http://www.kentico.com/docs/devguide/adding_custom_functions_to_tra.htm

Best Regards,
Juraj Ondrus

User avatar
Member
Member
gary.chan-e-crusade - 9/2/2008 5:10:11 AM
   
RE:Obtain document's last modified date
Hi Juraj,

Thanks for your help. It works fine for the NodeChildNodeCount one. For the DocumentModifiedWhen part, actually I need the latest modify date from children so when I use a repeater to list all parents, visitor knows which folder has new content.

Regards,
GC

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 9/2/2008 9:24:35 AM
   
RE:Obtain document's last modified date
Hi again,

In this case the solution is little bit complicated and there are three possible options. The first one which I will describe is the simplest but the performance could be affected because of multiple SQL queries. The other two are better in performance but more complicated to develop.

Here is the first option using nested repeater:
I have placed some news items (cms.news document type) under "News" and "Partners" documents (lets say into different categories). These parent documents are of type cms.menuitem.

On the master page I have placed a repeater with this configuration:

Path: /%
Document types: CMS.MenuItem
Maximum nesting level: 1 (to avoid menu item listing in deeper levels under the categories)
Where condition: NodeAliasPath LIKE '%News%' OR NodeAliasPath LIKE '%Partners%'
Transformation: CMS.MenuItem.Default
NestedControlsID: CMSRepeater12

If you have more news section, you need to specify them all in the where condition so the parent repeater is searching only these.

And now, the nested repeater is placed in the transformation:

MenuItemName: <%# Eval("MenuItemName") %><br />
ModifiedWhen:
<cms:CMSRepeater ID="CMSRepeater12" runat="server" Path=<%# Eval("NodeAliasPath") + "/%" %> ClassNames="cms.news" TransformationName="CMS.News.Default" OrderBy="DocumentModifiedWhen DESC" SelectTopN="1" >
</cms:CMSRepeater><br />

As you can see the path is set dynamically according to the current Node Alias Path. Also, there is another transformation. The output of this nested repeater is the top 1 item in the path, so in the transformation CMS.News.Default is only macro to resolve its modification date: <%# Eval("DocumentModifiedWhen") %>

So the final output that is displayed is only date and time. I hope it makes sense. As I mentioned, the performance could be decreased depending on how many sections you have. You may also modify the transformations to have better design outputs.


The second option is to use a query repeater web part where you will need to write custom query which will return appropriate date from the DB view or table.

The third option is to write custom function that will be used in the transformation (http://www.kentico.com/docs/devguide/adding_custom_functions_to_tra.htm) where you will also need to specify the SQL query and handle the returned dataset to get appropriate data.

I hope it will help.

Best Regards,
Juraj Ondrus