Portal Engine Questions on portal engine and web parts.
Version 4.x > Portal Engine > Add List in Content View modes: 
User avatar
Member
Member
ctaleck IPAGlobal - 3/19/2009 3:21:58 PM
   
Add List in Content
Is it possible to add a list using an inline control using piece of the content tree as the source? Basically I would like to transform a portion of my menu somewhere into my page content in ad-hoc manner.

(I'm basically being lazy here: I have a rather long and involved content tree, and I don't want to have to manually create the text and hyperlinks for portions of it everywhere I need to create a menu in my page content.)

User avatar
Kentico Developer
Kentico Developer
kentico_martind - 3/24/2009 10:16:40 AM
   
RE:Add List in Content
Hello,

you can use SelectNodes method in your inline control to get nodes of appropriate part of content tree. Please see http://www.kentico.com/docs/devguide/selecting_nodes.htm for more details.

Best Regards,

Martin Dobsicek

User avatar
Member
Member
ctaleck IPAGlobal - 3/24/2009 4:45:00 PM
   
RE:Add List in Content
I explored the idea of creating an "Inline Control" to implement this idea. I am new to Kentico and ASP.NET controls. It is a very clever concept but the programming (especially in C#) is a little bit beyond me.

Is there a repository of user-contributed Inline Controls?

User avatar
Member
Member
ctaleck IPAGlobal - 3/24/2009 5:14:47 PM
   
RE:Add List in Content
For example, I do not know how to display the dataset as given from this example in the documentation:

Select multiple documents



[C#]



DataSet ds = null;



// create a TreeProvider instance

CMS.TreeEngine.TreeProvider tree = new CMS.TreeEngine.TreeProvider();



// get dataset of tree nodes specified by alias path and class names (separated by semicolon),

// the second parameter says whether to return default culture documents if the required

// document language version is not available

ds = tree.SelectNodes("CorporateSite","/Products/%", "en-us", True, "cms.menuitem;cms.products");



// do something with dataset ...

User avatar
Member
Member
ctaleck IPAGlobal - 3/25/2009 3:32:26 PM
   
RE:Add List in Content
OK, here is the solution I "stumbled" upon.

First, I created a new ASP Control:


/CMSInlineControls/ShowNodeList.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ShowNodeList.ascx.cs" Inherits="CMSInlineControls_ShowNodeList" %>
<cms:CMSListMenu ID="CMSListMenu_NodeList" runat="server" />

/CMSInlineControls/ShowNodeList.ascx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class CMSInlineControls_ShowNodeList : CMS.ExtendedControls.InlineUserControl
{
protected void Page_Load(object sender, EventArgs e)
{
// Parameter input: "/NodeAliasName/%" (including quotes)
// need remove the '"' which is passed in
// because % terminates the input
// and %% is the macro delimeter for an inline control
String node = this.Parameter.Replace("&quot;", "");

// Set the path of the list menu to the new node
CMSListMenu_NodeList.Path = node;

// Reload the changed path
CMSListMenu_NodeList.ReloadData(true);

}
}



Second, I followed the directions provided above to activate the inline control.

Last, to use the control, insert this inline control code into any editable content area:

%%control:ShowNodeList?"/Path/To/Starting/Node 0/%"%%

You will get an unordered list of nodes under "Node 0" like this on your page:

* Node 1
    o Sub-Item 1
    o Sub-Item 2
* Node 2
    o Sub-Item 1
    o Sub-Item 2
* Node 3
    o Sub-Item 1


Style as needed and enjoy!

User avatar
Member
Member
ctaleck IPAGlobal - 3/25/2009 3:38:56 PM
   
RE:Add List in Content
ctaleck IPAGlobal wrote:
Second, I followed the directions provided above to activate the inline control.


Actually, this is in reference to another post I saw about creating inline controls.

At any rate, the documentation covers it at:

how to develop inline controls

User avatar
Kentico Support
Kentico Support
kentico_zdenekc - 4/10/2009 5:40:32 AM
   
RE:Add List in Content
Hi,

thanks for sharing your findings and additions.

Regards,
Zdenek C.