i´m a bit stuck in my solution. I´m trying to use umbraco´s editorControls to put tagging in my custom control. The control is used for creating a document with tags. I have found out, how to use umbraco.editorControls.tags.DataType to get the tag-editor in to the control.
//tags
var tagKashmir = new umbraco.editorControls.tags.DataType();
phTagKashmir.Controls.Add(tagKashmir.DataEditor.Editor);
But i just can´t figure out, how to save the tags in my document. All other properties are saved like this:
var dt = DocumentType.GetByAlias("KashmirZoom");
var author = User.GetUser(AuthorId);
var titel = TitelKashmir.Text.Trim();
var content = ContentKashmir.Text.Trim();
DateTime eventdate;
DateTime.TryParseExact(((TextBox) phEventDateKashmir.Controls[0]).Text, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out eventdate);
var doc = Document.MakeNew(titel, dt, author, 1099);
doc.getProperty("content").Value = content;
doc.getProperty("eventdate").Value = eventdate;
//doc.getProperty("kashmirTags").Value = tags;
doc.Publish(author);
library.UpdateDocumentCache(doc.Id);
i did look in Blog4Umbraco yesterday, and didn´t find anything usable. In the folder "usercontrols" there is only a file for AjaxCommentForm.ascx and BlogInstaller.ascx. I found a control under "Dashboard" called CreatePost.ascx, but i see no tag-saving. Do you know exactly where to look?
I did this recently, I created a new DataType tag, so that I could give a unique tag group, clients in my case. This is so that you can keep your tags separate:
In the user control do what Rene was doing, up to and including the doc.publish. You now have the ID of the new documents (doc.Id).
Then check to see if the tag has been used before:
wow that's some pretty awesome code! When I try to add my tags to my usercontrol I get the exception that I need a scriptmanager.. When I add a scriptmanager I get the error that my tags aren't set to an object reference.. Any ideas how to solve this? private umbraco.editorControls.tags.DataType tags;
//ScriptManager script = new ScriptManager(); //this.Controls.Add(script);
tags = new umbraco.editorControls.tags.DataType(); this.Controls.Add(tags.DataEditor.Editor);
I just used a text box for the user to enter the tags, and drop down control to display tags that already existed, as that best suited our requirements. What are you trying to achieve with your code?
I'm trying to make a usercontrol so you don't have to login to the backend to make blogposts using the Blog4Umbraco package. I'm trying your code right now.
Saving tags in custom user control
Hi there,
i´m a bit stuck in my solution. I´m trying to use umbraco´s editorControls to put tagging in my custom control. The control is used for creating a document with tags. I have found out, how to use umbraco.editorControls.tags.DataType to get the tag-editor in to the control.
But i just can´t figure out, how to save the tags in my document. All other properties are saved like this:
I am getting nuts over this one.
Best regards
René
Hi Ithink you should take a look at the source code of Blog4Umbraco. That is using an Usecontrol to create posts with tags also. You'll find it here
Cheers,
Richard
Hi Richard
i did look in Blog4Umbraco yesterday, and didn´t find anything usable. In the folder "usercontrols" there is only a file for AjaxCommentForm.ascx and BlogInstaller.ascx. I found a control under "Dashboard" called CreatePost.ascx, but i see no tag-saving. Do you know exactly where to look?
Regards
René
Hi, I'm having the same problem. did you remember how you solved the issue?
Hi Thijs,
I did this recently, I created a new DataType tag, so that I could give a unique tag group, clients in my case. This is so that you can keep your tags separate:
In the user control do what Rene was doing, up to and including the doc.publish. You now have the ID of the new documents (doc.Id).
Then check to see if the tag has been used before:
If it is a new tag, you need to save the tag value entered into the DB table that contains the tags,
Where _tagGroup is "clients" in my example. You then need to save to DB that your new document is using the tag:
The update the cache:
The only comment, is that I was only receiving one tag value, where it may be possible to save multple comma separated tags in one go.
Richard
wow that's some pretty awesome code! When I try to add my tags to my usercontrol I get the exception that I need a scriptmanager.. When I add a scriptmanager I get the error that my tags aren't set to an object reference.. Any ideas how to solve this?
private umbraco.editorControls.tags.DataType tags;
To fix the script manager error, you need to add ScriptManager tag to the MasterTemplate:
I just used a text box for the user to enter the tags, and drop down control to display tags that already existed, as that best suited our requirements. What are you trying to achieve with your code?
Richard
I'm trying to make a usercontrol so you don't have to login to the backend to make blogposts using the Blog4Umbraco package. I'm trying your code right now.
I really appreciate your help!
Thijs
is working on a reply...