Brenden, I think I'm onto something. At least that's what I'm sticking to for this project I'm working on. Here's what I did:
- Created a new Directives custom table, with just the default fields.
- Add a single dummy record in there. (don't worry, the contents of the record is irrelevant)
- Then for each directive you need, add a new transformation.
-
In the Visual Studios solution, add a new ASPX Web Form. I'm calling mine GetSnippet.aspx.
Here's my aspx page.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GetSnippet.aspx.cs" Inherits="Website_Tools_GetSnippet" ViewStateMode="Disabled" EnableViewState="false" %>
<%@ Register Src="~/CMSWebParts/CustomTables/customtablerepeater.ascx" TagPrefix="uc1" TagName="customtablerepeater" %>
<%--Gets the name of the snippet required from the query string, and gets the related layout from the directives custom table.--%>
<uc1:customtablerepeater runat="server" ID="customtablerepeater" CustomTable="site.Directives" />
-
Here's the Page_Load in the code behind for GetSnippet.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
string directiveName = Request.QueryString["name"];
if (!String.IsNullOrEmpty(directiveName)) {
customtablerepeater.TransformationName = "crown.Directives." + directiveName;
}
}
So in the templateUrl option for the directive's javascript, you can now set it as /Site/Tools/GetSnippet.aspx?name=header and it would get you the snippet for the header.
One thing to think about is, what should it serve if the name passed through the querystring is invalid?