Sett inn navn på forfatter automatisk

Vote:
 
Vi skal bruke byline i våre artikler. Dvs, at navn og epost-adresse for forfatter automatisk settes inn i dedikerte tekstfelt allerede i editor. Dette fordi det skal være mulig for forfatter å sette inn en annen persons navn og epostadresse i de tilfeller der man publiserer innhold på vegne av andre. Har noen gjort liknende erfaringer der man populerer data i tekstfelt i editor? Tips mottas med takk! Mvh, Frank Langva
#17375
May 06, 2005 10:23
Vote:
 
Hi. Possibly more easy ways to do this, but here goes... You can either create your Property which inherits from PropertyString. (See the Code Samples section on this web site for examples on how to create your own properties). You set this property to fill the text box with the DisplayName or Email from the current logged in user. Then, when editing this page later, it will display whatever text it was saved with. Another approach is to do this in the CreatingPage event. Check the page type of the page you are trying to create, and if the new page has the WriterName property, fill this with DisplayName or Email from the current logged in user. Also, I think this way, you also have to determine the name of the text box you want the data to go into. Maybe someone else has some input on how to do this. Either way, the text box (when creating a new page) will be filled out with DisplayName or Email (or whatever you want...) from the current logged in user. I am also certain I saw some sample code on this somewhere, either in the forum or in the SDK. Couldn't find it right now, though... Frank :)
#18085
May 06, 2005 12:39
Vote:
 
Use the CreatingPage event, and assign values to the properties directly. if (PersonalizedData.Current != null) e.Page["Writername"] = PersonalizedData.Current.DisplayName; Steve
#18086
May 06, 2005 14:06
Vote:
 
En annan snygg variant ær att skapa en egen property, så att man sjælv kan vælja att skapa en egenskap som ær førifylld. [EPiServer.PlugIn.PageDefinitionTypePlugIn(DisplayName="Page responsible")] public class userName:PropertyString { public override void CreateChildControls( string renderType, System.Web.UI.Control container) { UnifiedPrincipal user = UnifiedPrincipal.Current; switch(renderType) { case "edit": TextBox txt = new TextBox(); txt.ID = this.Name; txt.Width = 270; CopyWebAttributes(container,txt); if (user != null && user.Identity.IsAuthenticated) txt.Text = user.UserData.FirstName + " " + user.UserData.LastName; if ((string)base.Value != null) txt.Text = base.Value.ToString(); container.Controls.Add(txt); container.Controls.Add(CreateParseValidator(txt)); break; default: base.CreateChildControls(renderType,container); break; } } }
#18087
Jul 08, 2005 13:34
* 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.