Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > Custom Slideshow Web Part - Getting files View modes: 
User avatar
Member
Member
brandonm-salespad - 5/8/2012 10:32:48 AM
   
Custom Slideshow Web Part - Getting files
I've successfully created a custom web part / widget that will allow my editors to drop in a slideshow. The problem that I'm having now is that I'm not exactly sure how to get the images under the slideshow. The approach that I'm attempting right now, which very well could be incorrect so please feel free to recommend a better way, is that I have a property on the web part that allows them to select a directory. In the code behind of the slideshow web part, I'm attempting to loop through the files under that directory. This is where I hit a roadblock because I essentially have no idea how to access these files.

P.S. The ideal situation would allow me to iterate through 'images' that have the path to the image file (.jpg or .png) and some text. I though the 'file' objects would work because I could use the description field as the text for the slide.

Thanks in advance!

User avatar
Member
Member
brandonm-salespad - 5/9/2012 2:24:32 PM
   
RE:Custom Slideshow Web Part - Getting files
Thanks to another post I made, I have solved / had this problem solved for me. I created a slide object that holds an image/file and a caption as properties. From the Slideshow widget code behind, I create a repeater and get the HTML output from transform for the objects placed in the directory specified in the slideshow widget. Here's my code behind for reference for anyone else maybe coming across this later.

protected void Page_Load(object sender, EventArgs e)
{
slide_script_wrapper.InnerHtml = string.Format("<script>{0}</script>", AddSlides());
}

protected string AddSlides()
{
Page pageHolder = new Page();
CMSRepeater repeater = (CMSRepeater)pageHolder.LoadControl(typeof(CMSRepeater), null);

//Set Parameters.
repeater.ClassNames = "custom_1023.slideshow_slide";
repeater.Path = GetValue("ImageDirectory").ToString();
repeater.TransformationName = "custom_1023.slideshow_slide.Default";

pageHolder.Controls.Add(repeater);
StringWriter output = new StringWriter();
HttpContext.Current.Server.Execute(pageHolder, output, false);

return output.ToString();
}