Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Web Parts combination View modes: 
User avatar
Member
Member
litvin5-tut - 8/10/2010 7:56:18 AM
   
Web Parts combination
Hi there.

As a new user of your excellent CMS I'd like to know how can I create my own web part, which will be consist of the others kentico web parts?
I've already read the tutorial about web part creation, but this requirement has not been explained.

Now I need to make a combination of image gallery, content rating and message board web parts. I've already embed content rating into image gallery transformation, but there is one issue - I can't perform alignment that I need - this control is always placed on the left side.

Then I've tried to embed message board like the content rating control with this piece of code:
<%@ Register Src="~/CMSWebParts/MessageBoards/MessageBoard.ascx" TagName="MessageBoard" TagPrefix="cms" %>

And I'd like to afford anonymous posts.

But the only thing I've seen is the text "There are no messages.<br/><br/>". Text boxes and other controls are hidden by the reasons I don't know, but they must be enabled and visible.

So can anybody tell me what's wrong with my attempts?

I appreciate any help

User avatar
Member
Member
kentico_michal - 8/18/2010 1:11:18 AM
   
RE:Web Parts combination
Hi,

Well, it is possible to create web part, that consist of another web parts, but it is not recommended way, since it may cause some issues.

Maybe you could consider using controls instead of web parts, if it is possible e.g. Message board web part use message board control that you can find in ~\CMSModules\MessageBoards\Controls\MessageBoard.ascx.cs.

Best Regards,
Michal Legen

User avatar
Member
Member
litvin5-tut - 8/18/2010 4:48:57 AM
   
RE:Web Parts combination
Thanks for suggestion.

But this is not I've expected. I need a functionality that will be represent some kind of upgraded image gallery - the image gallery that contains content rating for each image and possibility to comment this image. For comment purpose I'd like to use message board. I don't want to use embedded content rating in message board - 'cause any image can be rated but the comments writing is not necessary.

So the variant using message board control instead of webpart makes no sense - the results are the same. The command controls are still invisible if I'll try to include message board into image gallery webpart or in the transformation.

Sorry for so complicated way of explaining my trouble, but I can't do it better. Maybe you can suggest anything else possible?

User avatar
Member
Member
kentico_michal - 8/19/2010 8:25:34 AM
   
RE:Web Parts combination
Hi,

Could you please explain what does not work correctly.

What do you mean exactly with expression "command controls"?


Best regards,
Michal Legen

User avatar
Member
Member
litvin5-tut - 8/20/2010 12:48:59 AM
   
RE:Web Parts combination
Hello,

Ok, let me explain

The way that I've choosen is to register all the necessary controls in transformation file. This file called default.ascx looks like this:

<%@ Register Src="~/CMSWebParts/ContentRating/ContentRating.ascx" TagName="RatingControl" TagPrefix="cms" %>
<%@ Register Src="~/CMSModules/MessageBoards/Controls/MessageBoard.ascx" TagName="MessageBoard" TagPrefix="cms" %>

<table style="text-align:center">
<tr>
<td><%# Eval("ImageName") %></td>
</tr>
<tr>
<td><%# GetImage("Image") %></td>
</tr>
<tr>
<td>
<cms:RatingControl ID="RatingGallery" runat="server" />
</td>
</tr>
<tr>
<td>
<cms:MessageBoard ID="GalleryBoard" runat="server"/>
</td>
</tr>
</table>

Everything looks fine, but while the content rating control is visible and enabled for voting, the only thing that I can see at the place of message board control is a plain text "There are no messages<br/><br/>". And I can't see the fields for posting a comment - all the text boxes and the button are invisible. I wonder why.
This is a first way to go.

The other thing that I've discovered is to perform paging in the transformation file.
I need this to repeat the default image gallery functionality. But I feel this will be very tricky stuff to do.

So what can you advise?

User avatar
Member
Member
kentico_michal - 8/20/2010 4:22:47 AM
   
RE:Web Parts combination
Hi,

Please take a look at following example code with MessageBoard web part, that you can use in transformation:


<%@ Register Src="~/CMSWebParts/MessageBoards/MessageBoard.ascx" TagName="MessageBoard" TagPrefix="cms" %>

<cms:MessageBoard ID="messageBoardASPX" runat="server" MessageTransformation="community.transformations.MessageBoard" NoMessagesText="There are no messages." EnableViewState="false" />

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
this.messageBoardASPX.BoardAccess = CMS.SiteProvider.SecurityAccessEnum.AllUsers;
this.messageBoardASPX.BoardOwner = "document";
this.messageBoardASPX.ShowApprove = true;
this.messageBoardASPX.ShowDelete = true;
this.messageBoardASPX.ShowEdit = true;
this.messageBoardASPX.ShowReject = true;
this.messageBoardASPX.BoardRequireEmails = true;
this.messageBoardASPX.BoardUseCaptcha = true;
this.messageBoardASPX.BoardOpened = true;
this.messageBoardASPX.EnableAnonymousRead = true;
this.messageBoardASPX.WebPartTitle = "MessageBoardASPX";
this.messageBoardASPX.ReloadData();
}
</script>


Best regards,
Michal Legen

User avatar
Member
Member
litvin5-tut - 8/20/2010 4:45:55 AM
   
RE:Web Parts combination
Thanks a lot. This really helped

User avatar
Member
Member
pfrauholle - 10/7/2010 3:08:39 AM
   
RE:Web Parts combination
Hi, that helped me too :-)

One other question regarding the form. How can I change the textbox in the transformation in order to not retrieve the username by default. Instead I would like to allow users to write their own name into the textbox.

The reason for that is because the messageboard is shared by many people having just one single login. If they now leave all a comment, then the name would be the same on each of the comment.

Thansk for your help!

Regards,
Patricia

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 10/8/2010 3:44:50 AM
   
RE:Web Parts combination
Hello,

to leave fields blank by default you can change the public override void ClearForm() method in the file
~\CMSModules\MessageBoards\Controls\Messages\MessageEdit.ascx.cs to look like this one:

public override void ClearForm()
{
txtUserName.Text = String.Empty;
txtEmail.Text = String.Empty;
txtMessage.Text = String.Empty;
txtURL.Text = "http://";

//if (!CMSContext.CurrentUser.IsPublic())
//{
// txtUserName.Text = !DataHelper.IsEmpty(CMSContext.CurrentUser.UserNickName) ? CMSContext.CurrentUser.UserNickName : CMSContext.CurrentUser.FullName;
// txtEmail.Text = CMSContext.CurrentUser.Email;
//}
}


Best regards,
Ivana Tomanickova

User avatar
Member
Member
pfrauholle - 10/13/2010 12:48:18 AM
   
RE:Web Parts combination
Hi, thanks for your response. I adjusted the code in the file mentioned above, but the username does still appear in the textbox after loggin into the page which contains the messagebaord.

I'm using version 4.1. Are they any other suggestions, please?

Thanks,
Patricia

User image

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 10/13/2010 10:28:41 AM
   
RE:Web Parts combination
Hi,

Could you please call ClearForm() method from the Page_Load method in the following file:
~\CMSModules\MessageBoards\Controls\Messages\MessageEdit.ascx.cs


protected void Page_Load(object sender, EventArgs e)
{
Response.Write("som fakt tu");

// Let parent check 'Modify' permission if required
if (!RaiseOnCheckPermissions(PERMISSION_MODIFY, this))
{
// Parent page doesn't check permissions
}

this.SetContext();

// Initialize the controls
SetupControls();

this.ReleaseContext();
ClearForm();

}


Calling this method from Page_Load method makes fields empty.

Best regards,
Ivana Tomanickova

User avatar
Member
Member
pfrauholle - 10/13/2010 8:36:28 PM
   
RE:Web Parts combination
Thanks again for your suggestion. Unfortunately by following your example and calling the Clearform() in the page load the form will not pass the validation and nothing can be submit.

What is still missing?

Cheers,
Patricia

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 10/15/2010 6:15:44 AM
   
RE:Web Parts combination
Hi,

Could you please remove ClearForm() method from the Page_Load() method?

One additional modification of method private void SetupControls() is needed:

Could you please replace following code:

else
{
// Fill form with default data
txtURL.Text = "http://";
if (!CMSContext.CurrentUser.IsPublic())
{
txtUserName.Text = !DataHelper.IsEmpty(CMSContext.CurrentUser.UserNickName) ? CMSContext.CurrentUser.UserNickName : CMSContext.CurrentUser.FullName;
txtEmail.Text = CMSContext.CurrentUser.Email;
}
}


with


else
{
// Fill form with default data
txtURL.Text = "http://";
if (!CMSContext.CurrentUser.IsPublic())
{
txtUserName.Text = String.Empty;
txtEmail.Text = String.Empty;
}
}


Using this additional modification fields are empty and submit will not cause a validation error.

Best regards,
Ivana Tomanickova

User avatar
Member
Member
pfrauholle - 10/15/2010 8:39:22 PM
   
RE:Web Parts combination
Thanks a lot. that was the solution! :)