1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / How to display custom field in Blog page

How to display custom field in Blog page

8 posts, 0 answered
  1. Keen
    Keen avatar
    10 posts
    Registered:
    28 Dec 2008
    06 Feb 2009
    Link to this post
    Hi,
    I've added a new custom field in the Blog Module. After adding the blog to a page, how to display this custom field. Currently it's showing publication date, link to Comments, Full Story.

    I have one more question, How can the user create a new blog post from the Blog Page (i don't see any link for posting).
    Thanks for your help
    Keen
  2. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    06 Feb 2009
    Link to this post
    do you mean you added a new custom meta field? as laid out here: http://www.sitefinity.com/help/developer-manual/how-to-gc-based-add-custom-meta-fields.html, when you add a field to web.config for a module, you have two additional steps: 1) add the input field to the admin control templates (both insert and edit pages)  and 2) add the output field to the public control template.

    for blogs, the templates are located here:

    Admin:
    \Sitefinity\Admin\ControlTemplates\Blogs\ControlPanelInsert.ascx
    \Sitefinity\Admin\ControlTemplates\Blogs\ControlPanelEdit.ascx

    Public:
    \Sitefinity\ControlTemplates\Blogs\Modes\ListPageDetail.ascx

    regarding a new blog post, if I'm not mistaken, these can only be created in the sitefinity administration, so you'd have to have them login. you could make a link to yoursite.com/sitefinity/admin/Modules.aspx?module=Blogs on your blog page to get them started in the right place.

    hope this was helpful!
  3. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    06 Feb 2009
    Link to this post
    Hi Keen,

    If you want to display the metafield that you have created you should edit the templates  under

    - lists all posts
    ~Sitefinity\ControlTemplates\Blogs\Modes\ListPageMaster.ascx
    - lists single post
    ~Sitefinity\ControlTemplates\Blogs\Modes\ListPageDetails.ascx

    For instance you could add a new Literal control. Example:
    <asp:Literal ID="Author1" runat="server" ></asp:Literal> 

    Here the ID of the control is the same as AssociatedControlID property of the Label control.
    <asp:Label ID="Label3" AssociatedControlID="Author1" runat="server"
    <asp:Literal ID="Literal10" runat="server" Text="Author1"></asp:Literal> 
    <em id="AuthorLabel" runat="server"></em></asp:Label> 
    <asp:TextBox ID="Author1" Text="Author1" runat="server" MaxLength="250"></asp:TextBox> 
    <class="example"><asp:Literal ID="Literal11" runat="server" Text="Author1"></asp:Literal></p
     

    I hope this helps.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  4. Jeff
    Jeff avatar
    124 posts
    Registered:
    05 Aug 2007
    07 Feb 2009
    Link to this post
    I'm struggling with this too. I've read the article SelArom over and over again but I'm still missing something.

    Here's what I've done:

    Web.config:

    <

     

    add key="News.Subtitle" valueType="ShortText" visible="True" searchable="False" sortable="False" defaultValue="" />


    Sitefinity\Admin\ControlTemplates\News\ControlPanelInsert.ascx:

     

     

    <sfGCn:ContentMetaFields ID="editMetaFields" runat="server">

     

     

     

     

     

        <ItemTemplate>

            ...

     

     

            <fieldset class="set">

     

     

     

     

     

                <ol class="setIn">

     

     

                    <li>

     

     

     

     

     

                        <asp:Label ID="Label9" AssociatedControlID="Subtitle" runat="server"><asp:Literal ID="Literal24" runat="server" Text="<%$Resources:Subtitle %>"></asp:Literal> <em id="SubtitleLabel" runat="server"></em></asp:Label>

     

     

     

     

     

                        <asp:TextBox ID="Subtitle" TextMode="MultiLine" Text="" runat="server"></asp:TextBox>

     

     

     

     

     

                    </li>


    When I try to add a new article through this URL:
    /Sitefinity/Admin/Modules.aspx?module=News&mode=insert

    I get:

     

    Parser Error

    Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

    Parser Error Message: The resource object with key 'Subtitle' was not found.


    I think I've done everything I'm supposed to. Is there a database schema that needs to be updated or something?

    Thanks,
    Jeff

     

  5. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    08 Feb 2009
    Link to this post
    oh okay the problem is that in the label for subtitle, you're using a Resource Reference:

    Text="<%$Resources:Subtitle %>">

    This is the .resx file that lets you localize the output...

    replace it with Text="Subtitle" and you should be good to go!

    hope this was helpful!
  6. Jeff
    Jeff avatar
    124 posts
    Registered:
    05 Aug 2007
    08 Feb 2009
    Link to this post

    Wonderful! Thanks SelArom.

    The final code looks like this and works wonderfully. Hopefully my HTML is easier to read this time in a code block. :)

     

                        <li> 
                            <asp:Label ID="Label9" AssociatedControlID="Subtitle" runat="server"><asp:Literal ID="Literal24" runat="server" Text="Subtitle"></asp:Literal> <em id="SubtitleLabel" runat="server"></em></asp:Label> 
                            <asp:TextBox ID="Subtitle" TextMode="MultiLine" Text="" runat="server"></asp:TextBox> 
                        </li> 

    Looking back on the article, it never said to do use the Resources: format. That came from copying and pasting a nearby addtribute.

    Thanks agian for your help.

    Jeff

     

  7. Keen
    Keen avatar
    10 posts
    Registered:
    28 Dec 2008
    10 Feb 2009
    Link to this post
    Hi,
    Thanks for your replies.
    I already manage to add a new field (Rating) in Blog module. From the admin site, everthing is fine (can post ,edit ,display new blog post with this new field).
    But from the public site, i'm still unable to display the Rating field.
    What I dis is I put :

     Rating:<asp:Literal ID="Rating" runat="server" ></asp:Literal>


    (~Sitefinity\ControlTemplates\Blogs\Modes\ListPageMaster.ascx)

    It's showing nothing after Rating.

    When I replace this field by an existing field, let say View_Count. it's not showing also.

    Regards,
    Keen
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    10 Feb 2009
    Link to this post
    Hello Keen,

    Most probably the ID of the Literal control is not the same as the ID of AssociatedControlID and the TextBox ID.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Register for webinar
8 posts, 0 answered