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

Forums / Developing with Sitefinity / Edit Sitefinity Database externally

Edit Sitefinity Database externally

4 posts, 0 answered
  1. Andrei
    Andrei avatar
    553 posts
    Registered:
    27 Nov 2008
    27 Jul 2009
    Link to this post
    Hi,

    I am using Sitefinity 3.6 and trying to implement a feature on teh website. 

    The problem: The client needs to display an image on a page which is updated 4 - 6 times a day. 

    At the moment with Sitefinity I would have to implement a image viewer whcih refreshes itself every (lets say 5 seconds) and then link it to the image in question from the database. Then when it needs changing, I just re-upload it and since the page keeps refreshing every 5 seconds then the image should appear on all the displays in no longer than 5 seconds.

    I want to further simplify it for teh user and so I am wonderign if I can directly save the binary data for the image ints current record in teh database.

    I have had a look at the database and have seen the sf_CmsBinaryContent table along with sf_Libraries table too. The ID field in the CmsBinaryContent does not relate with any field in the Libraies table. Can you give me some directions here?

    Thank you very much.

    Andrei 

    I want to simplify it. I want to be able 
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    27 Jul 2009
    Link to this post
    Hi Andrei,

    I suggest that you should use Ajaxify Timer. You can set its Interval to 5000 ( 5 seconds). OnTick you can rebind the data.

    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.
  3. Andrei
    Andrei avatar
    553 posts
    Registered:
    27 Nov 2008
    27 Jul 2009
    Link to this post
    Ivan,

    Thanks for the reply. I have already done that. But with this solution I still have to re-upload the image
    through the 'Images & Documents' module for the actual image to change on the page. My issue is not with the refreshing of the page, but with changing the actual image in the database.

    I want to access a given image in the database and change its bunary data field. Can I do that externally?

    Thanks

    Andrei
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    27 Jul 2009
    Link to this post
    Hello Andrei,

    I prepared an example of a solution that does not require changing the data in the database which is not considered as a good practice.
    The example inherits from image( you can use another control) and checks the items in your library. Then divide the hours/minutes to the images and creates an index. So that our image will display images based on the created index.
    For instance we could set all items to be shown for 30 minutes and then repeat them.

    using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Web; 
    using System.Web.UI.MobileControls; 
    using System.Collections; 
    using Telerik.Cms.Engine; 
    using Telerik.Libraries; 
    using System.Web.UI; 
     
    /// <summary> 
    /// Summary description for Rotator 
    /// </summary> 
    public class RotatorImage : System.Web.UI.WebControls.Image 
        public string LibraryName 
        { 
            get
            set
        } 
     
        public RotatorImage() 
        { 
        } 
     
        protected override void Render(System.Web.UI.HtmlTextWriter writer) 
        { 
     
            var manager = new LibraryManager("Libraries"); 
            ILibrary lib = manager.GetLibrary(LibraryName); 
            int numberOfImages = lib.ItemsCount; 
            DateTime now = DateTime.Now; 
     
            int imageIndex = now.Minute % numberOfImages; 
            //int imageIndex = now.Hour % NumberOfImages; 
            IList allImagesInLibrary = lib.GetItems(); 
     
            this.ImageUrl = ((IContent)allImagesInLibrary[imageIndex]).UrlWithExtension; 
     
            base.Render(writer); 
        } 
     


    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.
Register for webinar
4 posts, 0 answered