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

Forums / Developing with Sitefinity / Customizing the News module

Customizing the News module

12 posts, 0 answered
  1. Krishna
    Krishna avatar
    8 posts
    Registered:
    05 Sep 2008
    31 Oct 2008
    Link to this post
    Hi,
    I'm trying to customize the built-in News module. I added a few metafileds in the web.config and made changes to the Controlpaneledit and ControlPanelInsert controls. Upto this point everythinhg works as expected.

    I want to show this data in the public site. Fo this I modified SingleNews and NewsList controls to display the new data. I couldn't see my changes when I add NewsView control to my page. Please let me know if I'm doing anything silly here?

    Regards

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

    SingleNews and NewsList are obsolete controls. Actually,
    you need to modify public templates of the NewsView control:

    1. Open the following files:
      
    ~Sitefinity\ControlTemplates\News\Modes\ListPageMaster.ascx
       ~Sitefinity\ControlTemplates\News\Modes\ListPageDetails.ascx
    2. Declare the controls that will display the meta fields.
    3. Create a new control extending from the NewsView base class and override
    SetItemMetadata and SetListMetadata methods:
    4. Register the new control in the <toolboxControls> section of the project web.config file to display it in Add Controls toolbox.

    For details refer to the following Developer Manual topic:
    Example: Extending Content View Control

    Do let us know if you need any further assistance.

    Best wishes,
    Pepi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Andy
    Andy avatar
    62 posts
    Registered:
    01 Aug 2008
    03 Nov 2008
    Link to this post
    Hi,

    I'm working with Krishna on this. Thanks for the pointer.

    I've added an extra BigPicture metadata item to the News module, have created a custom control based on NewsView. and have the following line in the ..Master.ascx, which enables me to flexibly bind to that property without having to override SetItemMetadata

    <asp:Image ID="img200" runat="server" ImageUrl ='<%# Container.DataItem.GetMetaData("BigPicture") %>' />

    I'm having problems doing a similar thing in the Detail.ascx. Is it actually possible? If so, can you give an example.

    Many thanks,
    Andy
  4. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    04 Nov 2008
    Link to this post
    Hi Andy,

    You could try to declare an Image control in ~Sitefinity\ControlTemplates\News\Modes\ListPageDetails.ascx template and set its ID to the meta key like this:

    <asp:Image ID="BigPicture" runat="server" /> 

    Do let us know if this helps.

    All the best,
    Pepi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  5. Andy
    Andy avatar
    62 posts
    Registered:
    01 Aug 2008
    05 Nov 2008
    Link to this post
    Yes, that works great!

    Thanks Pepi!
  6. Andy
    Andy avatar
    62 posts
    Registered:
    01 Aug 2008
    06 Nov 2008
    Link to this post
    OK, re-visiting the Image in the Details.ascx for the extended news module.

    <asp:Image ID="BigPicture" runat="server" />  works fine for just setting the ImageURL

    However but I have two other metadata fields, one for the alt-text and one for the title for the image. How can I bind these fields to the AlternateText and Title attributes of the <asp:Image /> control?
  7. Ivan
    Ivan avatar
    478 posts
    Registered:
    16 Jun 2015
    06 Nov 2008
    Link to this post
    Hello Andy,

    please take a look at this blog post:
    http://blogs.sitefinity.com/Ivan/Post/08-07-03/metamaster_2008_finally_released_.aspx

    I've built a simple control that lets you map metafield values to the properties of controls. NOTE: It works only for the details mode, but that's what you are after anyway.

    I hope you'll find this information helpful. Let us know if there is anything else we can do for you.

    Greetings,
    Ivan
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  8. Andy
    Andy avatar
    62 posts
    Registered:
    01 Aug 2008
    06 Nov 2008
    Link to this post
    That's great Ivan, thank you!

    However, how can you map to attributes that aren't supported by the control you are mapping?

    eg, I need to get a value into the 'title' attribute of the <IMG>. Normally, you just put the attribute in the <asp:image>: and it get's ignored and passed through to the <IMG>. The Title attribute isn't present on the <asp:image> so how to I get the <IMG title="Hover-over text"> (for Firefox - IE is happy with alt)
    ?
  9. Ivan
    Ivan avatar
    478 posts
    Registered:
    16 Jun 2015
    10 Nov 2008
    Link to this post
    Hi Andy,

    Image control has a Tooltip property (Gets or sets the text displayed when the mouse pointer hovers over the Web server control.) as well as AlternateText property (Gets or sets the alternate text displayed in the Image control when the image is unavailable. Browsers that support the ToolTips feature display this text as a ToolTip.)

    More information on Image members can be found here:
    http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.image_members.aspx

    I hope you'll find this information helpful. Let us know if there is anything else we can do for you.

    Sincerely yours,
    Ivan
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  10. Andy
    Andy avatar
    62 posts
    Registered:
    01 Aug 2008
    10 Nov 2008
    Link to this post
    Thanks for the response Ivan.
     I'm sure I tried both of those. I'll try again, but nothing came out in the rendered HTML <IMG> tag.... I need to set the Title attribute on the <IMG>
  11. Ivan
    Ivan avatar
    478 posts
    Registered:
    16 Jun 2015
    10 Nov 2008
    Link to this post
    Hi Andy,

    I am sorry if it doesn't work (though I am pretty sure Tooltip should do the job), but you have another option. The meta mapping control is open source, so you could add a property on the <metaMapping> control, something like "renderAsAttribute" and then in the code which maps the meta values to properties add additional logic that renders the value as attribute. It should be pretty simple to implement, nevertheless let me know if you need assistance.

    Kind regards,
    Ivan
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  12. Andy
    Andy avatar
    62 posts
    Registered:
    01 Aug 2008
    10 Nov 2008
    Link to this post
    Aah, it seems that it is case sensitive, and it's 'ToolTip' not 'Tooltip'
    Silly me. Now I get the 'Title' attribute rendered.

    Thanks Ivan! :-)
Register for webinar
12 posts, 0 answered