More in this section

Forums / Developing with Sitefinity / Adding a meta field to Events module and customizing the ControlPanelInsert and Edit control templates

Adding a meta field to Events module and customizing the ControlPanelInsert and Edit control templates

12 posts, 0 answered
  1. Marko
    Marko avatar
    148 posts
    Registered:
    30 Jul 2008
    24 Oct 2008
    Link to this post
    I added a field called Event_Type to the Events module, and everything works fine, except for one thing.  In ControlPanelInsert.ascx and ControlPanelEdit.ascx files, I'd like to have the Event Type entry field displayed directly below the Title field, and before the Description field. 

    However, when I look at the code in ControlPanelEdit and ControlPanelInsert, the <sfGCn:ContentMetaFields> section is below the Description field, and I don't know how to insert Event Type between Title and Description fields, without moving all of the other meta fields up there.  I'd like something like this:

    Title...
    Event Type...
    Description...
    Location...
    etc.

    Is that even possible to do without some extreme development and customization?
  2. Joe
    Joe avatar
    138 posts
    Registered:
    24 Sep 2012
    24 Oct 2008
    Link to this post
    Hello Marko,

    Thanks for contacting us.

    This would not require too much development. Below the Title section of both the controlpaneledit.ascx and the controlpanelinsert.ascx files, insert this code:

    <%--Test--%> 
                        <br /> 
                        <br /> 
                        <fieldset class="set"
                        <h3><asp:Literal ID="Literal14" runat="server" Text="Event Type"></asp:Literal></h3
                        <div class="setIn title"
                            <asp:TextBox ID="Event_Type" Text="" runat="server"></asp:TextBox> 
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="Event_Type" 
                                Display="Dynamic" EnableViewState="False" CssClass="validMessage" SetFocusOnError="True"
                                <strong> 
                                    <asp:Literal ID="Literal13" runat="server" Text="<%$Resources:TitleEmpty %>"></asp:Literal></strong></asp:RequiredFieldValidator> 
                        </div> 
                        </fieldset> 

    Your end result would look like the attached screenshot. Once this is in place, add the meta field to the Web.config as shown below:

                    <add key="Events.Event_Type" valueType="ShortText" visible="True" searchable="True" sortable="True" defaultValue=""/> 
     


    To use a drop down list, you must create a user control with the drop down list. Then wrap its selected value property into a public property that implements the ITextControl interface. For more info on adding meta fields, please read Adding Custom Fields in our User Manual. I hope that I have provided a solution to your technical issue. Feel free to contact us if you need further assistance.

    All the best,
    Joe
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Marko
    Marko avatar
    148 posts
    Registered:
    30 Jul 2008
    24 Oct 2008
    Link to this post
    Joe,

    Those instructions in the manual are exactly what I followed in the first place.  If you look in the "Adding Custom Fields" section in the manual, the STEP 3 says that you should put the custom meta field within the <sfGCn:ContentMetaFields ID="editMetaFields"> element.  Does that mean that it MUST be located within that element?  When I try your approach above, the input field shows up in the interface just fine, but it doesn't SAVE anything.  If I type "test 1 2 3" in the box, and hit Save, nothing gets stored.

    Now, if I just MOVE that section of code further down, and place it within the <sfGCn:ContentMetaFields ID="editMetaFields"> element, then it saves fine.

    ???
  4. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    27 Oct 2008
    Link to this post
    Hi Marko,

    In order to enable templates to save the meta field, the field must be added to the following container:

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

    This means that currently the required functionality cannot be achieved.

    We are sorry for misleading you in the previous post.

    Regards,
    Pepi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  5. Marko
    Marko avatar
    148 posts
    Registered:
    30 Jul 2008
    27 Oct 2008
    Link to this post
    Hmm, I thought so.  That's too bad.

    Thanks for following up.

    I haven't tried this, but... what about taking the Description field (which is not a meta field, as you know) and moving it down to <sfGCn:ContentMetaFields> section (after the Event Type field)?  Would that work or would it *think* that Description is a meta field and therefore, fail to save?
  6. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    28 Oct 2008
    Link to this post
    Hi Marko,

    Description (actually, this field represents the event content) is not a meta field. So it must be declared outside of ContentMetaFields control. You could put the Description field before or after meta fields container but not inside it.

    Kind regards,
    Pepi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  7. Marko
    Marko avatar
    148 posts
    Registered:
    30 Jul 2008
    28 Oct 2008
    Link to this post
    Thanks. I thought that would be the case.  OK, no big deal, I guess I'll live with it placed either where it is now or at the bottom of the page (after the ContentMetaFields control).

    Something unrelated, though (ok, somewhat related)...  Is there a way to remove the default "type your content here..." blurb from the content editor?  I couldn't find where that is set.  Basically, I'm changing the ControlPanelEdit and ControlPanelInsert so that the Description (content) field is NOT required any more, so it seems better if I just have it blank, by default.  Is this a quick change, or somethnig that would require extending of the module?  If latter, then I'll just leave it as is, not worth the extra work.
  8. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    28 Oct 2008
    Link to this post
    check the App_LocalResources folder, that's where most of the messages are set. you can either change them there, blank them, or just remove the 

    $Resources:VARIABLE

    from inside the Text or Value attributes for each input field, and replace it with your own. that's what I do.

    hope this was helpful

  9. Marko
    Marko avatar
    148 posts
    Registered:
    30 Jul 2008
    28 Oct 2008
    Link to this post
    That's what I thought, but I can't find a string "type your content here" anywhere in the App_LocalResources.  Most other field names, descriptions, examples, and similar are controlled via App_LocalResources, it seems, but not for the Content Editor (RadEditor).  Tthis might be embedded into the code for RadEditor, and I don't know how I would override that locally (just for the Events module).  I don't really want to extend any classes to achieve this, becuse it's not that big of a deal for me.  But if there IS a quick and easy way, I'd like to know it.
  10. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    30 Oct 2008
    Link to this post
    Hello Marko,

    "Type your content here..." message is an embedded resource that is set in the module implementation. The resource is compiled in the module assembly and you cannot change/remove it.

    Regards,
    Pepi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  11. Kiearn
    Kiearn avatar
    6 posts
    Registered:
    07 Aug 2008
    22 May 2009
    Link to this post
    Hi

    I'm using version 3.6 and the ControlPanelEdit and ControlPanelInsert files don't exist. How would I implement this in this version.

    Thanks
    Kieran
  12. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    22 May 2009
    Link to this post
    Hi Kiearn,

    You should map the external templates for the desired module. Please check out the following KB article How to map an external template

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Register for webinar
12 posts, 0 answered