rt @johncscott #umbraco a way to pass the ID of the current page to a .net user control using advanced parameter syntax EG: <umbraco:Macro CrewId="[#id]".?
what on earth does that all mean!? :)
i have a template which is showing an xslt macro
and passing parameters to the page using advanced parameter syntax
I failed to get this working through the parameter so I wrote this code to set the parameter to the current page ID in the event that the parameter value was empty instead.
passing @id to XSLT macro
rt @johncscott #umbraco a way to pass the ID of the current page to a .net user control using advanced parameter syntax EG: <umbraco:Macro CrewId="[#id]".?
what on earth does that all mean!? :)
i have a template which is showing an xslt macro
and passing parameters to the page using advanced parameter syntax
<umbraco:Macro MealId="1" CrewId="[#id]" Alias="[uc]TakenButton" runat="server"></umbraco:Macro>
so if a property of the document were crewMealId i can write
<umbraco:Macro MealId="1" CrewId="[#crewMealId]" Alias="[uc]TakenButton" runat="server"></umbraco:Macro>
and this is read correctly by the .net User Control ASCX
however if I would like to pass the node id of the current page being viewed in the template, an equivalent of $currentPage/@id
What is the best way to do this?
I'm sure I did this last week - I'm just checking through my POC files.
Is it not something like <umbraco:Macro PageId="[$currentPage]" Alias="[uc]Test" runat="server"></umbraco:Macro>
I'll get back to you in 15
thanks Keith
I failed to get this working through the parameter so I wrote this code to set the parameter to the current page ID in the event that the parameter value was empty instead.
using System;
namespace Umbraco_User_Controls.usercontrols
{
public partial class PageID : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (String.IsNullOrEmpty(CurrentPageID))
{
CurrentPageID = umbraco.NodeFactory.Node.getCurrentNodeId().ToString();
}
}
public string CurrentPageID { get; set; }
}
}
i get an error
'umbraco.presentation.nodeFactory.Node' does not contain a definition for 'getCurrentNodeId'
NO NO :D sorted
all very good
thank you that works a treat
TOP RESPECT TO KEITH
thank you again :)
You can just do this on page load:
Item item = new Item();
int pageId = int.Parse(item.PageElements["pageID"].ToString());
make sure you include: using umbraco.presentation.templateControls;
Works every time.
is working on a reply...