Yes, the Watcha, I am able to view everything w/ Visual Studio 2010 Ultimate ... .using YAF 1.95 but I really need to add 2 more fields to the registration page --- company name, and company phone ....
If you could help in any way, it would be truly appreciated!
Originally Posted by: jpweber
Sorry i dont have much time but i didnt forget you here is a little how to add 2 new Profile Fields. I tested it with YAF 1.96.1 but i also should work in 1.95. (In your Version its YAF.Classes.Utils instead of YAF.Utils also YAF.Classes.Core
First Create the Profile Fields in the Provider:
File YAF.Utils\YafUserProfile.cs
/// <summary>
/// Gets or sets the Company Name.
/// </summary>
[SettingsAllowAnonymous(false)]
[CustomProviderData("CompanyName;nvarchar;255")]
public string CompanyName
{
get
{
return base["CompanyName"] as string;
}
set
{
base["CompanyName"] = value;
}
}
/// <summary>
/// Gets or sets the Company Phone.
/// </summary>
[SettingsAllowAnonymous(false)]
[CustomProviderData("CompanyPhone;nvarchar;255")]
public string CompanyPhone
{
get
{
return base["CompanyPhone"] as string;
}
set
{
base["CompanyPhone"] = value;
}
}
And also to the Interface in
File: YAF.Types\Interfaces\IYafUserProfile.cs
/// <summary>
/// Gets or sets the Company Name.
/// </summary>
string CompanyName { get; set; }
/// <summary>
/// Gets or sets the Company Phone.
/// </summary>
string CompanyPhone { get; set; }
Add the New Field to the Register Page after Homepage
File: ..\pages\register.ascx
<tr>
<td align="right" class="postheader">
<asp:Label ID="HomepageLabel" runat="server" AssociatedControlID="Homepage">
<YAF:LocalizedLabel ID="LocalizedLabel13" runat="server" LocalizedTag="HOMEPAGE" />:</asp:Label>
</td>
<td class="post">
<asp:TextBox ID="Homepage" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td align="right" class="postheader">
<asp:Label ID="CompanyNameLabel" runat="server" AssociatedControlID="Homepage">
<YAF:LocalizedLabel ID="LocalizedLabel19" runat="server" LocalizedTag="COMPANYNAME" />
:</asp:Label></td>
<td class="post">
<asp:TextBox ID="CompanyName" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td align="right" class="postheader">
<asp:Label ID="CompanyPhoneLabel" runat="server" AssociatedControlID="Homepage">
<YAF:LocalizedLabel ID="LocalizedLabel20" runat="server" LocalizedTag="COMPANYPHONE" />
:</asp:Label></td>
<td class="post">
<asp:TextBox ID="CompanyPhone" runat="server"></asp:TextBox>
</td>
</tr>
Also edit the register.ascx.cs
var homepageTextBox = (TextBox)this.CreateUserWizard1.FindWizardControlRecursive("Homepage");
var companyNameTextBox = (TextBox)this.CreateUserWizard1.FindWizardControlRecursive("CompanyName");
var companyPhoneTextBox = (TextBox)this.CreateUserWizard1.FindWizardControlRecursive("CompanyPhone");
var dstUser = (CheckBox)this.CreateUserWizard1.FindWizardControlRecursive("DSTUser");
and
userProfile.Homepage = homepageTextBox.Text.Trim();
userProfile.CompanyName = companyNameTextBox.Text.Trim();
userProfile.CompanyPhone = companyPhoneTextBox.Text.Trim();
Now if you want to allow the user to edit this Properties
Add the new fields to the ..\controls\EditUserProfile.ascx
<tr>
<td colspan="2" class="header2">
<b><YAF:LocalizedLabel ID="LocalizedLabel8" runat="server" LocalizedPage="CP_EDITPROFILE" LocalizedTag="companyname" />
</b>
</td>
</tr>
<tr>
<td class="postheader">
<YAF:LocalizedLabel ID="LocalizedLabel9" runat="server" LocalizedPage="CP_EDITPROFILE"
LocalizedTag="companyname2" />
</td>
<td class="post">
<asp:TextBox runat="server" ID="CompanyName" CssClass="edit" />
</td>
</tr>
<tr>
<td colspan="2" class="header2">
<b>
<YAF:LocalizedLabel ID="LocalizedLabel8" runat="server" LocalizedPage="CP_EDITPROFILE"
LocalizedTag="companyphone" />
</b>
</td>
</tr>
<tr>
<td class="postheader">
<YAF:LocalizedLabel ID="LocalizedLabel9" runat="server" LocalizedPage="CP_EDITPROFILE"
LocalizedTag="companyphone" />
</td>
<td class="post">
<asp:TextBox runat="server" ID="CompanyPhone" CssClass="edit" />
</td>
</tr>
And load and save this fields in the EditUsersProfile.ascx.cs
this.HomePage.Text = this.UserData.Profile.Homepage;
this.CompanyName.Text = this.UserData.Profile.CompanyName;
this.CompanyPhone.Text = this.UserData.Profile.CompanyPhone;
and
userProfile.CompanyName = this.CompanyName.Text.Trim();
userProfile.CompanyPhone = this.CompanyPhone.Text.Trim();
The loading and saving is done now you may want to show this to field in the user Profile Page. ..\pages\profile.ascx
<tr runat="server" id="TwitterTR" visible="false">
<td class="postheader">
<YAF:LocalizedLabel ID="LocalizedLabel25" runat="server" LocalizedTag="Twitter" />
</td>
<td class="post">
<asp:Label ID="lbltwitter" runat="server" />
</td>
</tr>
<tr runat="server" id="CompanyNameTR" visible="false">
<td class="postheader">
<YAF:LocalizedLabel ID="LocalizedLabel30" runat="server" LocalizedTag="CompanyName" />
</td>
<td class="post">
<asp:Label ID="lblCompanyName" runat="server" />
</td>
</tr>
<tr runat="server" id="CompanyPhoneTR" visible="false">
<td class="postheader">
<YAF:LocalizedLabel ID="LocalizedLabel31" runat="server" LocalizedTag="CompanyPhone" />
</td>
<td class="post">
<asp:Label ID="lblCompanyPhone" runat="server" />
</td>
</tr>
and
the profile.ascx.cs
if (this.User != null && !string.IsNullOrEmpty(userData.Profile.Twitter))
{
this.TwitterTR.Visible = true;
this.lbltwitter.Text = this.HtmlEncode(this.Get<IBadWordReplace>().Replace(userData.Profile.Twitter));
}
if (this.User != null && !string.IsNullOrEmpty(userData.Profile.CompanyName))
{
this.CompanyNameTR.Visible = true;
this.lblCompanyName.Text = this.HtmlEncode(this.Get<IBadWordReplace>().Replace(userData.Profile.CompanyName));
}
if (this.User != null && !string.IsNullOrEmpty(userData.Profile.CompanyPhone))
{
this.CompanyPhoneTR.Visible = true;
this.lblCompanyPhone.Text = this.HtmlEncode(this.Get<IBadWordReplace>().Replace(userData.Profile.CompanyPhone));
}
And finally add the new language strings to the …/languages/english.xml
<Resource tag="HOMEPAGE">Home Page</Resource>
<Resource tag="HOMEPAGE2">Your Web Site (public):</Resource>
<Resource tag="COMPANYNAME">Company Name</Resource>
<Resource tag="COMPANYPHONE">Company Phone</Resource>
<Resource tag="COMPANYNAME2">The Name of your Company:</Resource>
<Resource tag="COMPANYPHONE2">Your Company Phone Number:</Resource>
If I don’t forget something you need to compile and you should have to new Profile Properties.
Edited by moderator
9 years ago |
Reason: Not specified