Hi,
I took at a look at your response and I think string replacement is probably the best way to go about this.
One could easily add module settings to the custom module they create and use the settings as their parameters. I will probably add an example of that soon.
Saved Query:
SELECT SiteName,Skin FROM mp_sites WHERE SiteID = $_SiteID_$;
Custom Module:
<%@ Control Language="C#" ClassName="QueryWithParams.ascx" Inherits="mojoPortal.Web.SiteModuleControl" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="mojoPortal.Business" %>
<%@ Import Namespace="mojoPortal.Business.WebHelpers" %>
<%@ Import Namespace="mojoPortal.Web.Framework" %>
<%@ Import Namespace="mojoPortal.Web.Controls" %>
<%@ Import Namespace="mojoPortal.Web.Editor" %>
<%@ Import Namespace="mojoPortal.Net" %>
<script runat="server">
/// <summary>
/// Author: Joe Davis
/// Created: 2017-06-16
/// Last Modified: 2017-06-16
///
/// The use and distribution terms for this software are covered by the
/// Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
/// which can be found in the file CPL.TXT at the root of this distribution.
/// By using this software in any fashion, you are agreeing to be bound by
/// the terms of this license.
///
/// You must not remove this notice, or any other, from this software.
///
/// </summary>
private SiteSettings siteSettings;
private string siteName = string.Empty;
private string siteSkin = string.Empty;
protected override void OnInit(EventArgs e)
{
siteSettings = CacheHelper.GetCurrentSiteSettings();
base.OnInit(e);
}
protected void Page_Load(object sender, EventArgs e)
{
LoadSettings();
ExecuteQuery();
PopulateControls();
}
private void ExecuteQuery()
{
SavedQueryRespository repository = new SavedQueryRespository();
SavedQuery q = repository.Fetch("QueryWithParams");
if (q == null) { return; }
StringBuilder query = new StringBuilder(q.Statement);
query.Replace("$_SiteID_$", siteSettings.SiteId.ToString());
using (IDataReader reader = DatabaseHelper.GetReader(string.Empty, query.ToString()))
{
while (reader.Read())
{
siteName = reader["SiteName"].ToString();
siteSkin = reader["Skin"].ToString();
}
}
}
private void PopulateControls()
{
litSiteName.Text = siteName;
litSkin.Text = siteSkin;
}
private void LoadSettings()
{
Title1.Visible = !this.RenderInWebPartMode;
if (this.ModuleConfiguration != null)
{
this.Title = this.ModuleConfiguration.ModuleTitle;
}
}
</script>
<asp:Panel ID="pnlWrapper" runat="server" CssClass="panelwrapper ">
<portal:ModuleTitleControl ID="Title1" runat="server" />
<asp:Panel ID="pnlForumStatsChart" runat="server" EnableViewState="false" CssClass="modulecontent">
<span><strong>Site Name:</strong></span> <asp:Literal ID="litSiteName" runat="server" /><br />
<span><strong>Skin:</strong></span> <asp:Literal ID="litSkin" runat="server" />
</asp:Panel>
</asp:Panel>
Hope this helps,
Joe