How to use Custom Field in BlogEngine?

If you are new to Blogengine and want to know how to set up blogengine for your new website check here.

After setting up our blog site using BlogEngine people stuck on how to use custom fields. They have doubts like can we do all the changes from the admin side itself or do we need to make code change and publish the files again.

This article will help you get a clear idea of how to use custom fields in the BlogEngine admin panel.

There are two ways you can add custom fields.

  • Custom Fields for a Profile
  • Custom Fields for a Post

Custom Field for a Profile
To add a custom field for a Profile User we have to enable the multiuser option in the web.config file. In web.config file go to appsettings in the XML tag and change the default value of BlogEngine.UsageScenerio from singleblog to multiusers. The three usage scenarios are also commented just above the key field setting.


After saving the web.config file, login to the admin panel by navigating to http://www.<yourdomain>.com/admin. Go to the profile section under the menu Users.

 Now Click the Custom Field add button, a popup opens and there we can enter a unique key and value. The value can be a string or HTML. What the custom fields do is, when we use this key in some places of the page the value in the Value field will be shown.

To be able to make the Custom field visible we have to add some jquery mark up in the postview.ascx file.The File location is <root folder>/Custom/Themes/Standard/PostView.ascx.You have to open the file using a text editor like notepad or notepad++ or Visual Studio editor etc. The place and the content of the mark up to be added are shown below.

var user = new BlogEngine.Core.AuthorProfile("Admin");
var foo = "";
if (user.CustomFields != null && user.CustomFields["foo"] != null)
{
foo = user.CustomFields["foo"].Value;
}


 Custom Field: <%= foo %>

In the figure above you can see I have placed the custom field to show up just above the Body content.

Now you can see that our custom HTML will show up in all postview pages just above the post content as you can see in the below figure.

Custom Field for a Post

Take the post in which you are going to add the custom field then click on the customize link and enable the Customfield checkbox.

On the right side, a new field to add Custom Fields will be visible. Now click on the link and add the custom field in the same way as you have done for the User-specific custom field.

Now we have to add the mark up in the postview.ascx.The content to add and the screenshots are below.

 var pass = "";
    if (Post.CustomFields != null && Post.CustomFields["post-foo"] != null)
    {
        pass = Post.CustomFields["post-foo"].Value;
    }

 <div>Post Custom Field: <%= pass %></div> 

Since we have added the custom field below the post content it will be shown accordingly in the UI.

 

Hope everyone got a clear idea of how to add custom fields in BlogEngine. Custom fields are very powerful data structures .you can add more functionalities and extend the design of the pages using it.

Please refer to the BlogEngine page for custom field explanation.

Comment below if you have any doubts.

If you like the article and find it helpful please share it in your favourite social media sites.

Thank you have a great day!

Issues during setting up of BlogEngine

Here we discuss some of the common issues faced by most people when they start hosting their blog using BlogEngine.Net.For the basic installation setting please refer to setting up BlogEngine.

I am talking about the latest version of blogengine as per writing this article i.e version: 3.3.8.0.

  1. Navigate to the ftp folder in which we are suppose to host the website files and upload the zip file downloaded from the website of blogengine.
  2. Unzip the contents of the file.
  3. Allow write permission to the folders App_Data and Custom.

  4. Update the trust level in the web.config file, uncomment the line and change the value from Medium to Full.


  5. Now you will be able to view the site at http://www.<yourdomain>.com.
    Type http://www.<yourdomain>.com/admin to login to the admin panel, you could see a similar screen once you login.

After above steps your blog site will be up and running.If you face any other issues during deployment please comment below.

How to Configure Email setting in Blogengine admin for gmail

Below I will explain how to configure the Email setting for your blogengine website when you host in the GoDaddy server.

First, log in to Admin side using URL:http://www.yourdomain.com/admin

In the left side, menu navigate to SETTINGS > E-mail

Fill in the email address of the Gmail account and password. In the SMTP Server field instead of smtp.gmail.com put relay-hosting.secureserver.net.This is for the GoDaddy hosting provider this setting may be different for other hosting providers.

Also, change the port number from 587 to 25.
The subject prefix is the default heading of the email when we receive email through our website using the credentials of this Gmail account provided in the admin side.

After you enter the following details test the Email using TEST EMAIL SETTING.

Enjoy using Blogengine.