Link to create a new page?

Vote:
 

How can I access the url that is used when you right click in view mode and choose "new"? Do I have to create it myself or can EPiServer provide it for me? The SDK calles it QuickNew, but I haven't found any documentation about it.

I'm adding a link button to my news lists to create a new news item. I need to make it easier for users who almost never create or edit pages.

We're running CMS 5 R2.
/Markus

#51459
Jun 09, 2011 11:12
Vote:
 

Not sure if this is what you are looking for:
(btw. I didn't find that EPiServer provided the url's out of the box) 

http://yoursite/ui/edit/Default.aspx?id=<pageId>&mode=createpage

For simple editing: &mode=simpleeditmode

You could also append "&epslanguage=xx" for specifying language. (if creating languagebranch of existing page. etc.)

-Svein Inge-

#51554
Edited, Jun 14, 2011 21:40
Vote:
 

Thank you Svein Inge

I've created a usercontrol which creates the link for me. It works fine on my startpage, but I when I tried using it on a subpage(country.aspx) the createhere string is always null. I don't get it. I can set a test label as <%#Container.CurrentPage.PageLink %>", but not the string createhere.

Any ideas on why the value is null on some pages?
/Markus

 

--------------NewPage.ascx.cs-------------------

public partial class NewPage : EPiServer.UserControlBase

{

public String createhere { get; set; }

protected void Page_Load(object sender, EventArgs e)

{

if (createhere != null)

{

//create page reference from createhere(parent newslist)
PageReference pr = newPageReference(Convert.ToInt16(createhere));
 

//get page from reference
PageData _page = GetPage(pr);

//If current user is allowed to create a new page, then create the link
if (_page.ACL.QueryDistinctAccess(AccessLevel.Publish) && PrincipalInfo.HasEditAccess)

{

//use variable createhere as id
string id = createhere.ToString();
//Fetch the sites url
string siteurl = Settings.Instance.SiteUrl.ToString();
//Fetch url for UI
string edit = Settings.Instance.UIUrl.ToString();
//Remove ~/ from the UIURL
edit = edit.Remove(0, 2);

//Make a create url
linkbutton.PostBackUrl = siteurl + edit + "edit/default.aspx" + "?id=" + id + "&mode=createpage";

linkbutton.Visible = true;

}

}

}

}

-------------Country.aspx--------------------

Footer in my episerver:pagelist. Looks the same on my working default.aspx.

<FooterTemplate> 

<development:newpage ID="Newpage1" createhere="<%#Container.CurrentPage.PageLink %>" runat="server"/>

 <asp:Label id="label" Text="<%#Container.CurrentPage.PageLink %>" runat="server"/>

</FooterTemplate>

#51658
Jun 20, 2011 10:25
Vote:
 

Maybe you are missing a databind.

For debugging you could add the following to your usercontrol:  CREATEHERE CURRENTVALUE: <%#createhere %>
You could also override databinding in your usercontrol's codebehind and set a breakpoint to see if databind is fired.

#51663
Jun 20, 2011 11:04
Vote:
 

I was missing a databind, added one to my linkbutton in the usercontrols page load.

Everything is working now, thank you again :)
/Markus

#51668
Jun 20, 2011 12:55
Vote:
 

I noticed in the error log that my user control is having problems with the friendlyurl function. How can I create an url that can be converted to a friendlyurl?

2011-09-06 09:40:20,812 ERROR [5] EPiServer.Web.FriendlyHtmlRewriteToExternal.IsHtmlUrlValidForRewrite - Invalid path encountered: WebForm_DoPostBackWithOptions(new%20WebForm_PostBackOptions(%22ctl00$fullRegion$PageList1$ctl02$newpage$linkbutton%22,%20%22%22,%20false,%20%22%22,%20%22http://mydomain.com/episerver/UI/edit/default.aspx, Exception: System.Web.HttpException: 'WebForm_DoPostBackWithOptions(new%20WebForm_PostBackOptions(%22ctl00$fullRegion$PageList1$ctl02$newpage$linkbutton%22,%20%22%22,%20false,%20%22%22,%20%22http://mydomain.com/episerver/UI/edit/default.aspx' is not a valid virtual path.
   at System.Web.VirtualPath.Create(String virtualPath, VirtualPathOptions options)
   at System.Web.VirtualPathUtility.Combine(String basePath, String relativePath)
   at EPiServer.Web.FriendlyHtmlRewriteToExternal.IsHtmlUrlValidForRewrite(UrlBuilder contextUrl, UrlBuilder url)

#53368
Sep 06, 2011 9:51
Vote:
 

The issue with friendlyUrl was solved by switching from a link button to an ordinary link(A href..).

#53455
Sep 09, 2011 8:38
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.