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

Forums / Developing with Sitefinity / Overriding the Publication_Date format

Overriding the Publication_Date format

10 posts, 0 answered
  1. Mike
    Mike avatar
    208 posts
    Registered:
    10 Dec 2007
    22 Oct 2008
    Link to this post
    Hi,

    I'm trying to tweak the news module (SF 3.2) to customize the display.  One of the things I'd like to do is change the format of the publication date.  In ListPageDetails.ascx, there is a literal for the publication date. I noticed it had a formatting placeholder in the text attribute (e.g. {0} ), so I figured this would work:

    <p class="sf_newsDate">
    <asp:Literal ID="Publication_Date" runat="server" Text="{0:dd MMMM yyyy}" />
    </p>

    However, this seemed to have no effect at all.  So then I created a NewsViewExtender, and tried to override the DatesFormat property, hard coding it to that same format string, but still Publication_Date comes out in it's default format (e.g. 10/15/2008  12:00:00 AM).

    This would be easier to figure out if I had the source code to the News module...

    Is there another way?  What am I missing here?

    Thanks,
    Mike

  2. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    22 Oct 2008
    Link to this post
    Hello Mike,

    You could replace the Literal control with Telerik.Cms.Web.UI.DateTimeLiteral control like this:

    ~/Sitefinity/ControlTemplates/News/Modes/ListPageDetails.ascx
    <class="sf_newsDate"
            <sfWeb:DateTimeLiteral ID="Publication_Date" runat="server" DateFormatString="dd MMMM yyyy"
            </sfWeb:DateTimeLiteral> 
    </p> 

    Thanks for your cooperation in advance.

    Kind regards,
    Pepi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Mike
    Mike avatar
    208 posts
    Registered:
    10 Dec 2007
    22 Oct 2008
    Link to this post
    PERFECT!

    I love the easy answers.  Thanks Pepi!


    One more question:  same topic, different question.  ;^)

    In the news list control template, ListPageMaster.ascx, is there any way to identify the first ItemTemplate in the list?  I'm looking for a way to add a class like "first" or "last" to the first or last list item, so that I can add special formatting (in this case, I want a border-top on every item but the first one, similar to how the menu, tabstrip and panelbar controls work).

    ASP.NET provides an ItemSeparator, but to me that seems only useful if you're using table layouts.

    Thanks again for your great help!
    Mike
  4. Mike
    Mike avatar
    208 posts
    Registered:
    10 Dec 2007
    22 Oct 2008
    Link to this post
    Oh, wait...I figured out one way.  Maybe there's a better one, but this will work for now:
    <li class="<%# DataBinder.Eval(Container, "ItemIndex", "ListItemPosition{0}")%>">

    Now I can handle the first one differently by the class name.

    Regards,
    Mike

  5. Joe
    Joe avatar
    138 posts
    Registered:
    24 Sep 2012
    22 Oct 2008
    Link to this post
    Hi Mike,

    I just wanted to follow up. Have your technical issues been resolved?

    Regards,
    Joe
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. Mike
    Mike avatar
    208 posts
    Registered:
    10 Dec 2007
    22 Oct 2008
    Link to this post
    Yes they have, Joe. 

    Thanks!
    Mike
  7. nogatek
    nogatek avatar
    35 posts
    Registered:
    23 Apr 2008
    13 Jan 2009
    Link to this post
    Hi,

    I've tried to implement the DateTimeLiteral control as described above, but I'm getting "String was not recognized as a valid DateTime." errors, no matter how many different formatting strings I try.

    Here's my existing tag and what I want the string to be formatted too:

    <sf:DateTimeLiteral ID="Publication_Date" runat="server" DateFormatString="dd/MM/yyyy"></sf:DateTimeLiteral>

    Any ideas?

    Thanks, Mark


  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    14 Jan 2009
    Link to this post
    Hi Mark,

    Please open the following template  ~\Sitefinity\Admin\ControlTemplates\News\Design\NewsViewControlDesigner.ascx  and change TargetID="Publication_Date", FormatType to String. This will allow you to use string parameters in design mode.

    Add new data type to the dropdown
    ~\Sitefinity\Admin\ControlTemplates\Generic_Content\Design\TextSettingTemplate.ascx

    <asp:Panel ID="dateTimeFormatPanel" runat="server">  
                <asp:Label ID="lbl3" runat="server" Text="Date format" AssociatedControlID="dateTimeFieldFormat"></asp:Label>  
                <asp:DropDownList ID="dateTimeFieldFormat" runat="server">  
                <asp:ListItem Text="MyCustomDate" Value="f" ></asp:ListItem>          
                </asp:DropDownList>  
     

    Thus you will be able to change the time format in design mode adding additional items to the DropDownList.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  9. nogatek
    nogatek avatar
    35 posts
    Registered:
    23 Apr 2008
    19 Jan 2009
    Link to this post

    Hello Ivan,

    I went to implement your fix below, but in both instances there are no "Design" folders (i.e. the files you reference do not exist).

    I'm using SF v3.2.

    Is there another way to fix this? No matter what I try, SiteFinity seems detirmined to override the formatting of  this date string.

    Cheers, Mark

  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    20 Jan 2009
    Link to this post
    Hello Mark,

    If it is possible, please upgrade at least to 3.2 SP1. Then, you should be able to add new data type to the drop down. Which, I think is the best way.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

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