Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > User Contribution webpart - Separate page for new document? View modes: 
User avatar
Member
Member
Boolean - 4/2/2013 11:27:10 AM
   
User Contribution webpart - Separate page for new document?
Hi all

I'm using the Contribution List webpart to create a "New Document" link where users can post articles to the site. I'm following the tutorial on this page.

The issue I ran into is that I have a landing page that lists all my news items and at the bottom is my "New Article" button. When the user clicks the button and goes to the article creation page, the (rather long) list of news articles (as well as some header banners and other parts of the page) still show on the document creation screen.

What I would like to do is have a different page template for the news article creation screen, separate from the page structure that the "New Article" button is placed on. For example, in the document type settings I can set a "New Page URL", but I can't see how to combine that with the Contribution List webpart.

Can anyone think of a way around this?

User avatar
Kentico Support
Kentico Support
kentico_filipl - 4/5/2013 4:49:49 AM
   
RE:User Contribution webpart - Separate page for new document?
Hi,

You can take advantage of CMS.GlobalHelper.RequestStockHelper class which gives you ability to insert and get items into HttpContext.Current.Items collection using Add/GetItem methods. You can add a reference to a web part to the collection and retrieve it in the code of another web part.

Basically what you have to do is add a reference to the repeater in onContentLoaded() method in ~/CMSWebParts/Viewers/cmsrepeater.ascx.cs file using command:
CMS.GlobalHelper.RequestStockHelper.Add("repeater", this);

Then you can retrieve the Repeater web part in btnNewDoc_Click() method in ~/CMSModules/Content/Controls/UserContributions/ContributionList.ascx.cs file and set its Visible property to false like this:
if (CMS.GlobalHelper.RequestStockHelper.Contains("repeater"))
{
CMSAbstractWebPart repeaterWebPart = CMS.GlobalHelper.RequestStockHelper.GetItem("repeater") as CMSAbstractWebPart;
repeaterWebPart.Visible = false;
}

This way the articles in the repeater will not be listed while you are creating a new article.

Best regards,
Filip Ligac

User avatar
Member
Member
Boolean - 4/5/2013 1:01:17 PM
   
RE:User Contribution webpart - Separate page for new document?
Very cool, I didn't know about RequestStockHelper.

Thanks mate!