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

Forums / Developing with Sitefinity / Template Resources

Template Resources

6 posts, 0 answered
  1. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    03 Jul 2011
    Link to this post
    So using the backend template editor, has the syntax to include a resource changed?

    This is what's defined in the template

    <sf:FieldListView ID="Phone" runat="server"
        Text="<%$ Resources:EventsResources, ContactPhone %> {0}" Properties="ContactPhone, ContactCell"
        WrapperTagName="li"  WrapperTagCssClass="cme-event-single-details-phone"
    />

    But on the page, this is what gets rendered out
    <%$ Resources:EventsResources, ContactPhone %> 905xxxxxxx, 905xxxxxxx

    (instead of <strong>Phone</strong> 905xxxxxxx, 905xxxxxxx)
  2. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    16 Aug 2017
    06 Jul 2011
    Link to this post
    Hello Steve,

    It's because of the {0} you have inserted, as it places the string text and messes up parsing the resources text, actually the default syntax is:
    <sf:FieldListView ID="Phone" runat="server"
                    Text="<%$ Resources:EventsResources, ContactPhone %>" Properties="ContactPhone, ContactCell"
                    WrapperTagName="li"
                />
     By the way, since you mentioned you've used the backend template editor, don't you find using the built-in functionality for inserting fields int he template (located in the top right area on the template editor, where there's a list of the fields that can be included int he template) more convenient? This would always give you heads up of the default syntax which you can later try to modify as per your requirements. If you have any additional questions, please let us know, I'll be glad to help you further.

    Kind regards,
    Boyan Barnev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    06 Jul 2011
    Link to this post
    Well in 99% of the backend editor cases I'm just modifying existing templates, not using the right-hand snippits to make something from scratch :)

    So the whole {0} syntax was in the template already...

    I'll try this, thx
  4. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    07 Jul 2011
    Link to this post
    Hey Boyan,
      Here's an example:

    The News list templates defines the content like this

    <sf:FieldListView ID="NewsContent" runat="server" Text="{0}" Properties="Content" WrapperTagName="div" WrapperTagCssClass="sfnewsContent" />

    But if I delete that by accident, then re-add it via the right pane as you suggest, it gives me this

    <sitefinity:HtmlField runat="server" DisplayMode="Read" Value='<%# Eval("Content")%>' />

    ?

  5. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    16 Aug 2017
    08 Jul 2011
    Link to this post
    Hi Steve,

    Yes, that's true, however both will render the desired content. You can always refer to the default templates when creating/modifying a new one, as well if you prefer sticking to the default implementation. Have you tried the solution from my initial reply, as you correctly pointed out the {0} is automatically added by the control. Alternatively, you can get it with Eval like this:
    <sitefinity:TextField runat="server" DisplayMode="Read" Value='<%# Eval("ContactPhone")%>' />


    Best wishes,
    Boyan Barnev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    08 Jul 2011
    Link to this post
    Both do render the desired content...but they also don't ;)

    Like the other issue I mentioned...all of these controls still render extra hidden markup to my pages

    So this is what it wants me to use
    <sitefinity:TextFieldrunat="server"DisplayMode="Read"Value='<%# Eval("ContactPhone")%>' />

    ...but this renders out signifigantly less markup (but is more of a pain to impliment and we don't get the extra properties like WrapperTag)
    <asp:Label runat="server" Text='<%# Eval("ContactPhone")%>' Visible='<%# (Eval("ContactPhone") == null) ? "False" : "True" %>' />

    I've been using JustDecompile to try and figureout which of these to use and when....becasue clearly the templates were made for a reason using whatever version.
6 posts, 0 answered