Blog Post Author & Custom Field question
1 )When posting in a SF 4 blog, I notice in the template that it is supposed to display the author of the post in the list. I See "By | Date posted" but no name.
<
div
class
=
"sfpostAuthorAndDate"
>
<
asp:Literal
ID
=
"Literal2"
Text="<%$ Resources:Labels, By %>" runat="server" />
<
sf:PersonProfileView
runat
=
"server"
/>
<
sf:FieldListView
ID
=
"PostDate"
runat
=
"server"
Format
=
" | PublicationDate.ToLocal():MMM dd, yyyy"
/>
</
div
>
Hello Jon Ingersoll,
The field is populated by the values filled in your user registration (FirstName, LastName), can you please verify whether changing these fields will introduce some change.
Concerning custom fields for the blogs module, you can simply go to Sitefinity Backend -> Content -> Blogs and select Custom Fields for Blogs (rightmost section of your screen, somewhere in the middle). Please refer to the attached screenshot for more information. If you have any further questions, please do not hesitate to let us know.
Regards,
Boyan Barnev
the Telerik team
Boyan,
Thank you for the information. I went and checked my profile and my local user did not have a first and last name. This was my second local user so I think I forgot to enter the information this time around. So now my name is display on blog posts.
As for the custom field, what you sent is a custom field at the blog level, what I need is a custom field on the blog post object. Is there something in the admin for that?
-Jon
Hello Jon Ingersoll,
Yes, when you go to the posts for a given blog you have the option to specify custom fields for posts (same location in the Backend as for permissions for blogs)
All the best,
Boyan Barnev
the Telerik team
Boyan,
Thanks, that's what I was looking for. I must be losing my mind, I swear I looked on that page after you showed me how to set the custom field on the blog module.
I've setup the custom field that I need and it now shows in the backend blog post page. How would I go about setting this field programmatically in the codebehind of my custom usercontrol?
-Jon
Hello Jon Ingersoll,
You can use the GetValue() and SetValue() methods to operate with your custom filed programatically. I'm attaching a sample that's filtering blog posts based on certain taxonomies, I believe you might find it useful, as it is taking the value of the "Tags" custom field.
Greetings,
Boyan Barnev
the Telerik team
Boyan,
Sorry, but that code doesn't really help. I'm not trying to query the posts based on that field. I'm creating new posts via a custom form and submitting them. I don't see the getValue or setValue methods on the post object or the organizer object. How do I set the custom field value on the actual post object I've created?
This is the custom code I'm working on:
BlogsManager bManager =
new
BlogsManager();
BlogPost bPost = bManager.CreateBlogPost();
//title & content
bPost.Title = Title.Text;
bPost.Content = RadContent.Content.ToString();
bPost.UrlName = Title.Text.Replace(
" "
,
"-"
);
//Tag & Category
TaxonomyManager taxMan =
new
TaxonomyManager();
string
classYear = getClassYear(commonCode.getPersonID(Page.User.Identity.Name, commonCode.getSessionAuthenticationImplementationID(HttpContext.Current)));
if
(classYear !=
string
.Empty)
var tax = taxMan.GetTaxa<FlatTaxon>().Where(t => t.Name == classYear).Single();
bPost.Organizer.AddTaxa(
"Tags"
, tax.Id);
bPost.ApprovalWorkflowState =
"Published"
;
//set parent
bPost.Parent = bManager.GetBlogs().Single(b => b.Title == BlogName);
//publish
bManager.Publish(bPost);
bManager.SaveChanges();
Hello Jon Ingersoll,
Sorry about that, forgot to mention that you'll need to add reference to Telerik.Sitefinity.Model as Get/SetValue are extension methods.
Best wishes,
Boyan Barnev
the Telerik team
Did you get this to work? We need to do something similar.