If you look in the bottom part of the article you'll see how to get the name, a property etc. And if you want to grab the id you can simply do like this:
Node currenNode = Node.GetCurrent(); int id = currenNode.Id;
That way you don't have to worry about sending the as a param through the macro. But that's up to you :)
How do you pass the pageID to a macro?
Hello!
I am trying to pass the page ID to my usercontrol macro.
I have tried the following:
<umbraco:Macro ID="Macro1" CurrentMediaId='[#PageId]' Alias="Comments" runat="server"></umbraco:Macro>
' Alias="Comments" runat="server"></umbraco:Macro>
Hi Bex
You should be able to pass the current pages id like this:
<umbraco:Macro ID="Macro1" CurrentMediaId='[#pageID]' Alias="Comments" runat="server"></umbraco:Macro>
Almost like you already did, but with a lower 'p'.
/Kim A
Arrrrrrrrrrrrrrrrrrrrrgh!!
Lower case P!! that's the problem! Working now! Just worked it out as you posted!
Great ;)
In your c# you can also get the current page's id through the nodeFactory. There's a small guide in the Wiki about it: http://our.umbraco.org/wiki/reference/api-cheatsheet/working-with-the-nodefactory
If you look in the bottom part of the article you'll see how to get the name, a property etc. And if you want to grab the id you can simply do like this:
That way you don't have to worry about sending the as a param through the macro. But that's up to you :)
/Kim A
is working on a reply...