ASPX templates
Version 5.x > ASPX templates > Displaying folder and files from the content tree View modes: 
User avatar
Member
Member
neil-pursey - 8/24/2011 7:54:45 AM
   
Displaying folder and files from the content tree
Hi all

I have a site that requires the owners to publish folders and files that are under workflow and version control, for an individual user.
I am using the content tree rather than the a library as the client likes everything in the tree and it gives me full version control.

The content structure in the tree is along the line of:

Client (this is the main page for the clients folders and files)
-- Level 1 - Folder 1
---- Level 2 - Folder
------ Level 3 - Folder
-------- Level 4 - Folder
---- Level 2 - file
-- Level 1 - Folder 2
etc.

The client page is the root of the folder/file tree I want to display, the folders can go down to 4 levels.

I need to create an aspx template for the client page that displays a nice windows style explorer folder tree for the user that always displays the folder/file tree directly under it in the content tree.
- Links to files should open in a new window.
- Folder clicks should expand and collapse the folder.

I tried doing this by setting up nested repeaters. This works but is unacceptably slow when the user has 4 levels of folder and files, caching is not really an option as it is only that user that views the page.

I then tried using a /CMSWebParts/Navigation/cmstreeview.ascx web part.
I'm having real trouble configuring this to work as I would like. The folder clicks navigate to the URL of the folder and I end up loosing the other content on the page and navigating down the folder tree. There also seems no way of getting files to open in a new window.

Do you have any suggestions as the best way to approach this.

User avatar
Member
Member
kentico_michal - 8/25/2011 1:02:25 AM
   
RE:Displaying folder and files from the content tree
Hello,

It should be possible to accomplish by using the Menu properties of each document you are displaying. The CMSTreeView control takes into account these menu properties [click a document in the content tree -> Form tab -> Properties -> Menu -> Menu actions section].

There you could try to set the Inactive menu item property for folder documents to true.

Files documents need to have Standard behavior set to true.

In order to open Files documents in a new window, you could use a Target property of TreeView web part and set it to _Blank.

Best regards,
Michal Legen

User avatar
Member
Member
neil-pursey - 8/25/2011 5:10:50 AM
   
RE:Displaying folder and files from the content tree
Thanks Michal

This is working to an extent.

I'm testing at the moment and it's looking quite good and is much faster that the nested repeaters!
I'll be looking to automate this setting with custom event handlers (setting the menu item inactive for folders under certain paths).

We upload the files using the File Import.
Do custom event handlers get fired by this?

Regarding updating menu behaviours to be inactive in the database.
I've just gone into the database and updated the CMS_Document.DocumentMenuItemInactive field to 1 for the folders in my test, which works for the treeview but the menu properties page still shows standard behavious selected???

Is there somewhere else this needs to be updated?

I've also set the DisplayDocumentTypeImages="true" which shows a file icon for all files.
In the CMS tree the actual file type icon is shown (pdf, doc, etc). Is there anyway to set this up for the treeview?

Thanks
Neil

User avatar
Member
Member
kentico_michal - 8/29/2011 6:02:47 AM
   
RE:Displaying folder and files from the content tree
Hello,

In terms of the custom handler getting fired, the File import module creates standard documents of CMS.File (or CMS.Folder) document type. So, you can use custom tree node handler (Treenode handler).

Do you mean that settings that are available in the Properties -> Menu -> Inactive menu item / Standard behavior do not change where you change a value of DocumentMenuItemInactive column (True/False) directly in the database?

Regarding to images displayed by the TreeView control, these images are displayed based on the document type (CMS.File, CMS.News, CMS.Article etc.) instead of type of document that is uploaded in a document’s field. So, one way how to circumvent this limitation would be creating a new document type for each document you want to uplad, for example, CMS.PDF for pdf documents, CMS.DOC for office documents and so forth. Then, you can upload images you want to be shown in the TreeView control to the following folder ~/AppThemes/Default/Images/DocumentTypeIcons.


Best regards,
Michal Legen

User avatar
Member
Member
Neil Pursey - 8/29/2011 8:02:28 AM
   
RE:Displaying folder and files from the content tree
kentico_michal wrote:
In terms of the custom handler getting fired, the File import module creates standard documents of CMS.File (or CMS.Folder) document type. So, you can use custom tree node handler (Treenode handler).

done, thanks.

kentico_michal wrote:
Do you mean that settings that are available in the Properties -> Menu -> Inactive menu item / Standard behavior do not change where you change a value of DocumentMenuItemInactive column (True/False) directly in the database?

I do. If I update the DocumentMenuItemInactive field directly in the database via a query the Properties -> Menu still shows Standard behavour.
The treeview however, does pick up the field and doesn't create a link, as desired.

I now update these automatically via a custom treenode handler using

if (node.NodeClassName == "CMS.Folder") {
node.DocumentMenuItemInactive = true;
node.Update();
}

When done like this everything works OK.
e.g. TreeView and Properties -> Menu, shows Inactive menu.

kentico_michal wrote:
Regarding to images displayed by the TreeView control, these images are displayed based on the document type (CMS.File, CMS.News, CMS.Article etc.) instead of type of document that is uploaded in a document’s field. So, one way how to circumvent this limitation would be creating a new document type for each document you want to uplad, for example, CMS.PDF for pdf documents, CMS.DOC for office documents and so forth. Then, you can upload images you want to be shown in the TreeView control to the following folder ~/AppThemes/Default/Images/DocumentTypeIcons.

Yep, I don't think this is feasible as they are generally being bulk imported as CMS.File (about 100 at a time).
In the CMSDesk content tree the correct file type icons are shown according to the extension.
e.g. If I bulk import a bunch of word files they come into the system as CMS.File and shows in the CMS content tree with a word icon. Can this be duplicated in the treeview control?


Best regards,
Michal Legen[/quote]

User avatar
Member
Member
kentico_michal - 8/30/2011 3:02:13 AM
   
RE:Displaying folder and files from the content tree
Hello,

Regrettably, the CMSTreeView control is a part of source code, so it is not possible to modify it without source code of Kentico CMS. Anyway, there is a different method used to display icons in content tree. I am sorry for this limitation.

Best regards,
Michal Legen

User avatar
Member
Member
Neil Pursey - 8/30/2011 4:17:29 AM
   
RE:Displaying folder and files from the content tree
Can I request it goes onto a feature list please for a future release please.

User avatar
Member
Member
kentico_michal - 8/30/2011 5:11:23 AM
   
RE:Displaying folder and files from the content tree
Hello,

Sure, it is a great idea. I have already done so and it will be considered for a future version of Kentico CMS.

Best regards,
Michal Legen

User avatar
Member
Member
Snarrak - 1/9/2012 8:23:33 AM
   
RE:Displaying folder and files from the content tree
Hi,

Is it possible to set the target=_blank, only for the CMS.File-types in the TreeView?

Regards,
Jorik

User avatar
Member
Member
kentico_michal - 1/10/2012 3:32:04 AM
   
RE:Displaying folder and files from the content tree
Hello,

You will need to use the javascript that can look like the following javascript code in the Javascript command property [click the document in the CMS Desk -> Properties -> Javascript command] of the CMS.File documents that you are displaying:

Javascript command: window.open(this.href);return false;


Best regards,
Michal Legen