|
|
Rank: Devotee
Joined: 10/25/2007 Posts: 52
|
Hi everybody I'm struggeling creating a new data type/user control for the umbraco backend. I'm struggeling because I cannot find a way to get the current document (the one the usercontrol is located in). I need to get the ID of the document. I have tried the following in the PageLoad() method of the user control: Code:umbraco.presentation.nodeFactory.Node currentNode = umbraco.presentation.nodeFactory.Node.GetCurrent(); But that throws an exception: Code:[NullReferenceException: Object reference not set to an instance of an object.] umbraco.presentation.nodeFactory.Node.GetCurrent() +64 umbracoControls.FlashBanner.Page_Load(Object sender, EventArgs e) +165 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33 System.Web.UI.Control.OnLoad(EventArgs e) +99 Does anybody know if there is another API method I should use???? Thanks in advance :o) Kim
|
|
Rank: Devotee
Joined: 10/25/2007 Posts: 52
|
Hi again, Something got lost in the post. I have tried to use the following in the PageLoad method of the user control: Code:umbraco.presentation.nodeFactory.Node currentNode = umbraco.presentation.nodeFactory.Node.GetCurrent();
|
|
 Rank: Addict
Joined: 2/19/2007 Posts: 564 Location: Belgium
|
Hi Kim, If it is for a usercontrol that is used in the backend you can get the id by: Request["id"] Cheers, Tim
Umbraco tips and tricks: http://www.nibble.be - umbraco mvp 08/09 - certified level 1 & 2 professional
|
|
Rank: Devotee
Joined: 10/25/2007 Posts: 52
|
Hi Tim
Thanks for the info. That did the trick :o)
But is there an API method for retrieving the document and latest version based on the document ID???
Thanks in advance :o)
Cheers,
Kim
|
|
 Rank: Addict
Joined: 2/19/2007 Posts: 564 Location: Belgium
|
Sure there is, but I don't think it is recommended to use when you are making a new datatype. Code:
using umbraco.cms.businesslogic.web;
using umbraco.cms.businesslogic.property;
Document movie = new Document(Convert.ToInt32(docid));
if (isUnique(movie, txtEmail.Text))
{
DocumentType voteDocTyp = DocumentType.GetByAlias("Vote");
Document vote = Document.MakeNew(txtEmail.Text, voteDocTyp, new umbraco.BusinessLogic.User(0), movie.Id);
vote.getProperty("emailaddress").Value = txtEmail.Text;
vote.getProperty("subscribe").Value = cbPromotions.Checked;
vote.Publish(new umbraco.BusinessLogic.User(0));
umbraco.content.Instance.RefreshContentFromDatabaseAsync();
}
Umbraco tips and tricks: http://www.nibble.be - umbraco mvp 08/09 - certified level 1 & 2 professional
|
|
Rank: Devotee
Joined: 10/25/2007 Posts: 52
|
OK... Do you have alternative suggestions for accessing the current documents preview address??? E.g. Code:http://domain.dk/1041.aspx?umbVersion=4250f4d2-0c4d-44a5-987d-8049420784c3 Once again thanks for the input. It has been very helpful already :o) /Kim
|
|
 Rank: Addict
Joined: 2/19/2007 Posts: 564 Location: Belgium
|
Not really, try looking at the umbraco source code and finding out what code is behind the preview button
Umbraco tips and tricks: http://www.nibble.be - umbraco mvp 08/09 - certified level 1 & 2 professional
|
|
Rank: Devotee
Joined: 10/25/2007 Posts: 52
|
I'll try to have a look at it... Thanks a lot for your help so far :o)
Kim
|
|
|
Guest |