I am new to Kentico and am trying to write a custom web part for a jquery slide show plugin. I am having trouble getting it to work. If I post my code here will someone please let me know what I am doing incorrectly? Thank you.
This is the plugin I am using:
FlexsliderThe main script file is being registered correctly, but the init script that is supposed to be built off of the user's selection is not. Also, the transformation is not pulling the attached files.
My ascx file:
<%@ Register src="~/CMSWebParts/Viewers/Documents/cmsrepeater.ascx" tagname="cmsrepeater" tagprefix="uc1" %>
<uc1:cmsrepeater OrderBy="NodeOrder" ID="cmsrepeaterFlexslider" TransformationName="CMS.File.Flexslider" ClassNames="CMS.File" runat="server" EnableViewState="false" />
My ascx.cs file:
public partial class CMSWebParts_Access_Flexslider: CMSAbstractWebPart
{
#region "Public Properties"
/// <summary>
/// Gets or sets the value of IncludejQuery
/// </summary>
///
public bool IncludejQuery
{
get
{
return ValidationHelper.GetBoolean(this.GetValue("IncludejQuery"), false);
}
set
{
this.SetValue("IncludejQuery", value);
}
}
///<summary>
///Gets or sets the slide animation
///</summary>
///
public string Animation
{
get
{
return ValidationHelper.GetString(this.GetValue("Animation"), "");
}
set
{
this.SetValue("Animation", value);
}
}
///<summary>
///Gets or sets the path to the images
///</summary>
///
public string Path
{
get
{
return ValidationHelper.GetString(this.GetValue("Path"), "");
}
set
{
this.SetValue("Path", value);
}
}
///<summary>
///Gets or sets the slide control navigation
///</summary>
///
public string ControlNav
{
get
{
return ValidationHelper.GetString(this.GetValue("ControlNav"), "");
}
set
{
this.SetValue("ControlNav", value);
}
}
/// <summary>
/// Slide show speed
/// </summary>
///
public int SlideSpeed
{
get
{
return ValidationHelper.GetInteger(this.GetValue("SlideSpeed"), 7000);
}
set
{
this.SetValue("SlideSpeed", value);
}
}
/// <summary>
/// Slide show animation speed
/// </summary>
///
public int AnimationSpeed
{
get
{
return ValidationHelper.GetInteger(this.GetValue("AnimationSpeed"), 600);
}
set
{
this.SetValue("AnimationSpeed", value);
}
}
#endregion
/// <summary>
/// Content loaded event handler
/// </summary>
///
public override void OnContentLoaded()
{
base.OnContentLoaded();
SetupControl();
}
/// <summary>
/// Reloads data for partial caching
/// </summary>
///
public override void ReloadData()
{
base.ReloadData();
SetupControl();
}
/// <summary>
/// Initializes the control properties
/// </summary>
///
protected void SetupControl()
{
if (StopProcessing)
{
// Do Nothing
}
else
{
// Set path to slider images
cmsrepeaterFlexslider.Path = this.Path;
//Register jQuery
if (this.IncludejQuery)
{
ScriptHelper.RegisterJQuery(this.Page);
}
//Register Flexslider script
string flexsliderScript = "<script src=\"" + ResolveUrl("~/CMSWebParts/Access/Flexslider_files/jquery.flexslider.js") + "\" type=\"text/javascript\"></script>";
ScriptHelper.RegisterStartupScript(Page, typeof(string), ClientID + "script", flexsliderScript);
//Build slider options
string flexslideInit = "<script type=\"text/javascript\">(function($){ $(document).ready(function (){ $(\".flexslider\").flexslider({ animation:" + "\"" + this.Animation.ToString().ToLower() + "\"" + ", controlNav:" + "\"" + this.ControlNav + "\"" + ", slideshowSpeed:" + "\"" + this.SlideSpeed + "\"" + ", animationSpeed:" + "\"" + this.AnimationSpeed + "\"" + "}); }) })(jQuery);</script>";
//Register slider init script
ScriptHelper.RegisterStartupScript(Page, typeof(string), ClientID + "script", flexslideInit);
}
}
}
And this is my transformation:
<%# IfEmpty(Eval("FileAttachment"), "", "<li data-thumb=\"" + GetFileUrl("FileAttachment")+"?width=200\"" + "\>" + Eval("FileAttachment") + "</li>") %>