Technical support This forum is closed.
Version 1.x > Technical support > Newbie question - Page with free-form text (single article?) View modes: 
User avatar
Member
Member
cpaul - 3/24/2005 5:55:26 PM
   
Newbie question - Page with free-form text (single article?)
I'm creating a "catch all template" where users can add pages like "about us", "contact us", etc. I created an .aspx template containing a CMSViewer and the edit buttons. What I'd like (I think) is to display a single article as a sub-object under the Page, but when I click the New button in the editor, it creates the article as a top level object. I'm posting my .aspx code below.

Is this the right way to get a page of free-form text?

Thanks in advance


<cc1:CMSViewer id="CMSViewer1" runat="server" SelectNodesPath="" SelectNodesClassName="cms.article" TransformationName="cms.article.articletext"></cc1:CMSViewer>

<cc1:CMSEditModeButtons id="CMSEditModeButtons1" runat="server" SelectedNodeClassName="cms.article"></cc1:CMSEditModeButtons>

User avatar
Guest
admin - 3/24/2005 6:57:40 PM
   
Re: Newbie question - Page with free-form text (single article?)
Hello,

Thank you for this question. In this case, you need to use a solution like this instead of your current CMSEditModeButtons control:

<cc1:CMSEditModeButtons id="newButton" runat="server" SelectedNodeClassName="cms.article" DisplayEditButton="False" DisplayDeleteButton="False" DisplayPropertiesButton="False" Description="Create article:"></cc1:CMSEditModeButtons>

<cc1:CMSEditModeButtons id="editButton" runat="server" Description="Edit article:" DisplayNewButton="False" SelectedNodePathType="AliasPath" SelectedNodeClassName="cms.article" CMSDeskPath="~/cmsdesk" DisplayDeleteButton="False" DisplayPropertiesButton="False"></cc1:CMSEditModeButtons>

... and add the following code to the code behind, to the Page_Load method:

Dim ds As DataSet = Functions.GetTreeProvider.SelectNodes(Functions.GetAliasPath & "/%", TreePathTypeEnum.AliasPath, "cms.article")
If ds.Tables(0).Rows.Count = 0 Then
'allow creation of a new article
Me.newButton.Visible = True
Me.editButton.Visible = False
Else
'display editing buttons
Me.newButton.Visible = False
Me.editButton.Visible = True
End If

Should you need any help with this, please feel free to write me to petr.palas@kentico.com or post your question here.

Thank you.

User avatar
Member
Member
cpaul - 3/24/2005 8:43:24 PM
   
Re: Newbie question - Page with free-form text (single article?)
Thanks for the quick help. This worked, but I had to make one other modification (that I noticed in another thread in this forum), changing from SingleItem to MultipleItems in my viewmode. Is this necessary whenever the SelectNodePath has a wildcard character (or is default)?

User avatar
Guest
admin - 3/25/2005 8:00:28 AM
   
Re: Newbie question - Page with free-form text (single article?)
Well, in this case you need to use MultipleItems since you haven't specified any SelectNodePath. This means that the control will take the path of the currently selected page, automaticly adds wildcard at its end (e.g. /products/nokia/%) and displays all documents of the specified type on the page.

If you specify the SelectNodesPath value explicitely, you need to use appropriate ViewMode value (SingleItem for single node, MultipleItems for nodes specified using a wildcard).

Please let me know if you need more details.

Thank you.

User avatar
Guest
admin - 3/30/2005 9:31:05 AM
   
Re: Newbie question - Page with free-form text (single article?)
I've just realized that there's another, easier way how to do that. Here's an example:

<cc1:CMSEditModeButtons id="CMSEditModeButtons1" runat="server" SelectedNodeClassName="cms.article" DisplayDeleteButton="False"
DisplayPropertiesButton="False" SelectedNodePath="/products" DisplayNewButton="False" CMSDeskPath="~/cmsdesk"></cc1:CMSEditModeButtons>

Please note that the SelectedNodePath="/products" property specifies the page where the article is displayed and the SelectedNodeClassName="cms.article" property specifies the type of the document that should be edited/created.

When the editing dialog is opened, it tries to find the specified document of the specified type. However, the /products document is a page. Thus, it tries to search for child documents (/products/%) or type cms.article. If it finds some, it displays the editing form for the first child. If not, it displays the editing form for creating a new article under the /products document - it means you no longer need to use the "new" button.

I hope this helps. Should you need more details, please feel free to ask.