More in this section

Forums / Developing with Sitefinity / NewsView Control

NewsView Control

4 posts, 0 answered
  1. Dwayne Epps
    Dwayne Epps avatar
    6 posts
    Registered:
    04 May 2010
    17 May 2010
    Link to this post
    Is there a way to get the newsview control to make an image a clickable link to the actual news article?

    When I go to modules >> news and create a new item, I enter the title and then add a image that should be a link to the news article, but the problem is that the title shows up as the link and when I click on the title link, it then takes me to the news article with the image.

    I want to image to be the link to the news item.  How can I accomplish this?

    Thanks.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    17 May 2010
    Link to this post
    Hi Dwayne Epps,

    1. You need to map NewsItemNew and NewsItemEdit external templates - How to map a template
    2. Create a new metafiled that uses ButtonSelector control ( you could copy the declaration of the control from NewsItemNew and NewsItemEdit external templates ). You could use the button selector to set the image.

    3. Create a custom control that inherits from NewsView control and override SetItemMetadata method where you have access to each content item and metakey.

    4. In the ListPageMaster template that your custom NewsView control will use, inside the ItemTemplate of the Repeater control with ID="repeater" ( <asp:Repeater ID="repeater" runat="server">) add ASP.NET ImageButton control.

    5. In ListPageMaster template hide the title with css

    <h2 class="sf_newsTitle" style="display:none">
                <asp:HyperLink ID="fullContent1" runat="server">
                    <asp:Literal ID="Title" runat="server"></asp:Literal>
                </asp:HyperLink>
                <asp:Literal runat="server" ID="Litral1"/>
            </h2>

    6. Then inside SetItemMetadata get the value of metakey with value Title by using contentItem.GetMetaData method. (contentItem.GetMetaData("Title");)

    7. Inside SetItemMetadata find the ImageButton control -

    Control ctrl = base.FindContentViewControl("idOfImageButton", itemContainer);

    8. Set NavigateUrl to the value that (contentItem.GetMetaData("Title"); returns.  Get your custom image metakey by using contentItem.GetMetaData("MyCustomMetakey"); The value will return dynamic link. Resolve the dynamic link and set the value to ImageUrl of your ImageButton control.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Dwayne Epps
    Dwayne Epps avatar
    6 posts
    Registered:
    04 May 2010
    17 May 2010
    Link to this post
    Hi Ivan,

    Thanks for your response.  I read the article on how to map a template.  That seems pretty straightforward.

    I'm still unclear on items #2, #3, and #4.

    What is the metafiled?

    What and where is the ListPageMaster template?

    Are there any examples I can check out to help guide me thru the process below?

    Thanks again for your help.  I appreciate it.

    Regards.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    18 May 2010
    Link to this post
    Hi Dwayne Epps,

    Metafields are dynamic data fields that are used to persist data for IContent objects.Dynamic metafields -
    Any Generic Content based module can have dynamic meta fields attached to each content object. The meta fields are defined in web.config and require no additional coding (in terms of data access layer and persistence). So, for example, News module has meta fields such as “Author”, “Source”, Blogs module has meta fields such as “Title”, “Publication date”. To create different meta fields, a simple modification in web.config will suffice (and of course UI modification).

    For mapping a template, please take a look at  How to map a template


    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Register for webinar
4 posts, 0 answered