More in this section

Forums / Developing with Sitefinity / NewsView control

NewsView control

34 posts, 0 answered
  1. James@Nw
    James@Nw avatar
    265 posts
    Registered:
    05 May 2009
    15 Jun 2009
    Link to this post
    Hi Guys,

    In the News Module pages, I have added articles which have pdf attachements in them. I would like to display those attachments as links in the NewsView Control if that is possible?

    I have also created tags in the News Module articles. I need to pull those tags out and put them in the NewsView Control  control.

    Could you please let me know if this is possible?

    Thanks,
    James
  2. James@Nw
    James@Nw avatar
    265 posts
    Registered:
    05 May 2009
    15 Jun 2009
    Link to this post
    Here is an example of what I need in the end. Let me know if this makes sense?

    http://www.sixfoot.co.za/newsView.gif

    Thanks
    James
  3. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    16 Jun 2009
    Link to this post
    Hello James,

    This is possible but the approach will be slightly different.

    You need to define a new metafield, in which you will store the path to the pdf document. Then on the public part, you will be able to place the metafield anywhere in the NewsView control. Please let me know if you need further help with the defining and showing the metafield.

    Best wishes,
    Georgi
    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.
  4. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    17 Jun 2009
    Link to this post
    Hi Georgi,

    In your response:
    "You need to define a new metafield, in which you will store the path to the pdf document. Then on the public part, you will be able to place the metafield anywhere in the NewsView control. Please let me know if you need further help with the defining and showing the metafield."

    Can you provide a link or a description to describe a) How to add a meta field, and to what to add the metafield and b) How to place the metafield in the NewsView control.

    Regards,
    Jacques
  5. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    17 Jun 2009
    Link to this post
    Hi J.Hov,

    About adding new metafields you can take a look at our UserManual, section Add custom meta fields. You need to add the metakey value as <a href="your_link_here"></a> because the value should be rendered as a link on the public part. Then for the public part you can add a Literal control which should have the same ID as your metafield.

    Regards,
    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.
  6. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    17 Jun 2009
    Link to this post
    Hi Ivan,

    I've read the section in the User Manual, but I'm still rather confused about where you are suggesting we place the "<a href="your_link_here"></a>" value?

    We've got it up to the point now where the Attachment field appears in the NewsItemNew control, but we're using a textbox where we'd like to use some form of file picker. Is this possible?

    Regards,
    Jacques
  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    18 Jun 2009
    Link to this post
    Hello J.Hov,

    Here are the steps.

    1. Create a new metakey in your web.config file.

     <add key="News.test" valueType="LongText" visible="True" searchable="True" sortable="True" defaultValue=""/> 

    2. Add the metakey to NewsItemNew and NewsItemEditTemplate.

    example:

       <asp:TextBox ID="test" runat="server"></asp:TextBox> 


    3. Map NewsViewControlDesigner template.

        <viewSettings hostType="Telerik.News.WebControls.Design.NewsViewDesigner" 
                      layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/News/NewsViewControlDesigner.ascx" /> 

    4. Modify the ControlDesigner from step 3 and create a new TextSetting control for your metakey.
    This will allow you to convert the metakey as url and show it or hide it whenever you want.
    sample:

    <sfDesignSettings:PagingSetting id="pagingSetting" AllowListLimitSetting="true" DefaultListLimit="100" AllowPagingSetting="true" DefaultPageCount="10" LimitList="false" runat="server"></sfDesignSettings:PagingSetting> 
                        <h4>In the news page, display:</h4> 
                        <ul> 
                    </DetailHeaderTemplate> 
                    <DetailSettings> 
                      <sfDesignSettings:TextSetting ID="TextSetting16" 
                                                  TargetID="test"  
                                                  SettingTitle="test"  
                                                  AllowLabelSetting="True"  
                                                  AllowFormatSetting="True" 
                                                  FormatType="String" 
                                                  AllowVisibilitySetting="True" 
                                                  TargetVisibleByDefault="True"
                                                   </sfDesignSettings:TextSetting> 


    5. Map ListPageMaster and ListPageDetail templates and set the NewsView control to use them instead of the default one.

    6. Modify the templates from step 5.

    <HeaderTemplate> 
            <ul class="sf_newsList"
        </HeaderTemplate> 
        <ItemTemplate> 
            <li> 
            <asp:HyperLink ID="test" runat="server"></asp:HyperLink> 

    7. Then in the ControlDesigner set the format of the test metaky as url

    <href='http://{0}'>{0} 

    As for the picker you will have a problems getting the url. There is a ButtonSelector control which has a bug in the js and the value will be assigned to the first textbox if there are several. In this case you can have only one selector on the page.

    Regards,
    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.
  8. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    18 Jun 2009
    Link to this post
    Hi Ivan,

    I'm about to try what you have suggested, but I just wanted to confirm something with you.

    A) There will only be one attachment per article if any.
    B) Are you saying that we can have a URL selector? I'm not sure I saw from your sample how that would be possible?

    Regards,
    Jacques
  9. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    18 Jun 2009
    Link to this post
    Hi J.Hov,

    "As for the picker you will have a problems getting the url. There is a ButtonSelector control which has a bug in the js and the value will be assigned to the first textbox if there are several. In this case you can have only one selector on the page."


    You can create 10 atachments per items but you will not be able to select the url for each of them due to the bug. By Default the NewsItemNew and NewsItemEdit templates have one webeditor(selector). Therefore, you should change it or remove it and use another one.

    Kind regards,
    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.
  10. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    18 Jun 2009
    Link to this post
    Hi Ivan,

    Are these ten selector inputs supposed to appear when click "Create new item" in the news module?

    Regards,
    Jacques
  11. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    18 Jun 2009
    Link to this post
    Hi Ivan

    7. Then in the ControlDesigner set the format of the test metaky as url

    <href='http://{0}'>{0} 

    In the last point of your solution you mention setting the format of the test metakey to url.

    In the DetailSettings node I have the following extra node:
    <sfDesignSettings:TextSetting ID="TextSetting15"
                                                  TargetID="Attachement"  
                                                  SettingTitle="Attachment"  
                                                  AllowLabelSetting="True"  
                                                  AllowFormatSetting="True"
                                                  FormatType="Url"
                                                  AllowVisibilitySetting="True"
                                                  TargetVisibleByDefault="True">
                           </sfDesignSettings:TextSetting>

    Is that the correct FormatType where you intended for me to add URL?

    As for the:

    <href='http://{0}'>{0} 

    Where should this go?

    Regards,
    Jacques

  12. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    18 Jun 2009
    Link to this post
    Hi Ivan,

    I've changed this now to the following:
    In the DetailSettings node I have the following extra node:
    <sfDesignSettings:TextSetting ID="TextSetting15"
                                                  TargetID="Attachement"  
                                                  SettingTitle="Attachment"  
                                                  AllowLabelSetting="True"  
                                                  AllowFormatSetting="True"
                                                  FormatType="String"
                                                  AllowVisibilitySetting="True"
                                                  TargetVisibleByDefault="True">
                           </sfDesignSettings:TextSetting>


    This seems to be working and we see it in the control designer, but I still fail to see where the hyperlink code should go or how this is meant to work.

    Regards,
    Jacques
  13. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    18 Jun 2009
    Link to this post
    Hello J.Hov,

    In the metakey texbox you can add url like : sitefinity.com. If you re trying to add any html signs there you will get security error. This is the reason why we are creating a new property in the control designer where you should set the Metakey value as url. So, the newly created property "Attachement" has as Format. You should set the format ( step 7). <a href='http://{0}'>{0}. Thus the text you have entered in the textbox will appear as a hyperlink.

    Kind regards,
    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.
  14. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    18 Jun 2009
    Link to this post
    Sorry Ivan, that didn't make much sense to me at all. I'm getting more lost by the minute.

    If I was the editor of the article, where would I be loading the attachment? On which screen that is?
    If I'm just a reader of the site I would imagine the hyperlink as being where I would get my link to the document.

    I'm not sure where you're suggesting I put the <a .... tag

    In the ControlDesigner where the new attachment field is appearing I click on the link between the brackets which displays an area with two input boxes, text and value, but even if I enter values into them it doesn't get saved when I click Done.

    Help?


  15. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    19 Jun 2009
    Link to this post
    Hello J.Hov,

    I am sending you a video that illustrates the settings and how the control should work.

    All the best,
    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.
  16. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    19 Jun 2009
    Link to this post
    Hi Ivan,

    Thanks for the video clip.

    I've tried adding a value to the String Format field but it doesn't save it. If I go there the next time, the value that I entered is missing.

    Where am I going wrong here?

    Regards,
    Jacques
  17. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    19 Jun 2009
    Link to this post
    Hi J.Hov,

    Remove the control from the ContentPlaceHolder and then add it. Set all properties and check its behavior.

    Kind regards,
    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.
  18. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    19 Jun 2009
    Link to this post
    That worked, it's saving the value now, but...

    When the hyperlink renders to the browser only the second part of the string is formatted and replaced. There's no href in the a tag.

    I end up with a tag on the client side looking like this

    <a id="ctl00_Content_NewsView1_ctl00_ctl00_repeater_ctl01_Attachment">www.google.com</a>

    Why won't the href be replaced with the url I provided?


  19. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    19 Jun 2009
    Link to this post
    Hello J.Hov,

    You should have the following render:

    sample.

    <id="ctl00_SideBarContent_NewsView1_ctl00_ctl00_repeater_ctl01_test"/> 
    <href="http://www.telerik.com">www.telerik.com</a> 


    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.
  20. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    19 Jun 2009
    Link to this post
    I'm not getting that.

    So why would mine not work? I've gone through your instructions again points 1-7 and made sure everything is there and it seems right.

    What am I doing wrong?

    Regards,
    Jacques
  21. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    19 Jun 2009
    Link to this post
    Hello J.Hov,

    From the line you have sent it seems that the format rule(step 7) has not been applied for your Attachment setting. Check out the control again. Everything works fine at my end as you can see from the video I have sent you.

    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.
  22. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    22 Jun 2009
    Link to this post
    Hi Ivan,

    I managed to get your sample working now, but I have one more question to further this functionality.

    At the moment the link text ends up being the same as the href. Is there a way of allowing the user to specify the text and the URL?

    So you would essentially end up with a A tag as follows:
    <a href="www.nedoweb.com">Nedoweb</a>

    ?

    Regards,
    Jacques
  23. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    22 Jun 2009
    Link to this post
    Hi J.Hov,

    You can use the following string format and you should know the link so that you can write the text.

    <href='http://{0}'>MyURL</a> 

    Greetings,
    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.
  24. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    22 Jun 2009
    Link to this post
    Hi Ivan,

    Using your solution would mean that each link in the list would have the text MyUrl. This is fine to a degree, but what I'm wondering is if it's possible to allow the user to specify the text as well as the link.

    So you would end up with:
    <a href="www.nedoweb.com">Nedoweb</a>
    <a href="www.sitefinity.com">Sitefinity</a>

    Basically this means that one would need to be able to format the string so that the user specifies:
    <a href="UserSpecifiedUrl">UserSpecifiedText</a>

    I think it would help to understand better how this Metafield concept works, because I don't see how the asp:HyperLink in the ListPageMaster is merged with the format string and the values and then you end up with two A tags anyway. As in:
    <a id="ctl00_Content_NewsView1_ctl00_ctl00_repeater_ctl01_AttachmentUrl"/>
    <a href="http://localhost/SitefinityLabs/Libraries/Daily_Updates/Testdoc.sflb.ashx">Attachment</a>

    The online documentation doesn't go into much detail it seems and there don't seem to be many online samples that clearly describe the boundaries of this MetaField facility.

    Regards,
    Jacques
  25. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    22 Jun 2009
    Link to this post
    Hello J.Hov,

    The Format String property of the TexSettings control gets the all text from the metafiled and there are not parameters. So that we pass {0} - which is the first and it is the only one parameter that we can get. You can create a new metakey and persists the url text there.

    Best wishes,
    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.
  26. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    22 Jun 2009
    Link to this post
    Hi Ivan,

    Alright so there's only one parameter that can be used. Understood.

    But can you provide an example of how I would achieve what your suggesting with adding a second meta field to persist the text of the link.

    I tried by adding two metafields: AttachmentName and AttachmentUrl
    In the NewsItemNew and NewsIteEdit the user is able to specify values for each, but when it comes to the displaying of these values and the control designer I'm not sure how this would be achieved.

    I have tried
    <asp:HyperLink ID="AttachmentUrl" runat="server">
        <asp:Literal ID="AttachmentName" runat="server" />
    </asp:HyperLink>

    But I'm not sure how this works with the single parameter format string.

    Regards,
    Jacques

  27. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    22 Jun 2009
    Link to this post
    Hi Ivan,

    Any news on this solution?

    Regards,
    Jacques
  28. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    23 Jun 2009
    Link to this post
    Hi Ivan,

    Whilst we wait for your reply, we've had another crack at it, with no luck. We can't seem to put together how this solution should look if we want the article editor to be able to specify the link text and hyperlink separately.

    Regards,
    Jacques
  29. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    23 Jun 2009
    Link to this post
    Hi Ivan,

    We've got approval from the customer to go ahead with static text for the link text, but there's one last hurdle that we need to cover.

    The attachment link is showing up for every single article, whether it has an attachment or not.

    How do we hide it when the article has no attachment?

    Thanks,
    Jacques
  30. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    23 Jun 2009
    Link to this post
    Hi J.Hov,

    If there is not text you should not see anything in the list of items or in a single item mode. This is the reason why we use TextSettings and format options. The Format string should be empty if there is no value for the metakeys. Check out attached screenshot.

    Below is the solution with the two metafields.

    Steps:

    1. Create new metafiled
    2. Add the control to your template - ListPageMaster and ListPageDetails.
    3. Add the metakey to the Control designer
    4. Set the following format string - {0}</a>

    Note that the first control that will show the link should have the following string format <href='http://{0}'>

    All the best,
    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
34 posts, 0 answered
1 2