I am working a razor menu. The idea is that the client manually puts the menu on each language homepage(When I get the macro container to work :P).
I have to parameters they need to supply when inserting. The place to start the menu and the name of the homepage. The source parameter works fine. The frontPage parameter renders nothing and no errors.
My code looks like this:
@{ var startNodeID = Umbraco.Content(Model.MacroParameters["source"]); var homePage = Umbraco.Content(Model.MacroParameters["frontPage"]); }
When I use your code I get the name of the frontpage rendered. But not the value entered in the textbox macro parameter.
My site structure looks like this:
Danish homepage
- Subpages
Language version
- Language homepage
-- Subpages
On each new homepage the client inserts the menu with the macro container by filling out the contentpicker and the textbox with the custom name. The reason why I need the textbox parameter is because the nodes are named something like EN for english and DE for german and so on.
But in the menu I want them to enter something like Home, Start or Forside. So currentpage is not an option.
By the way, thank you very much for all the help :)
Ahhh! Well that's easy then! Your problem is using Umbraco.Content() for text fields - this is only for load an Umbraco content node (passing in the ID. To just get the text value use Model.MacroParameters["frontPage"] without that method - I'd also rename startNodeID as it's not the ID - it's the actual node content.
var startNode = Umbraco.Content(Model.MacroParameters["source"]); @* get an umbraco node from a picker *@
var homePage = Model.MacroParameters["frontPage"]; @* text value *@
Menu not displaying macro parameter value
Hi guys
I am working a razor menu. The idea is that the client manually puts the menu on each language homepage(When I get the macro container to work :P).
I have to parameters they need to supply when inserting. The place to start the menu and the name of the homepage. The source parameter works fine. The frontPage parameter renders nothing and no errors.
My code looks like this:
Any ideas on why I get no text?
/Michael
Try
No luck :(
Hmmm
Have you checked that you've got the correct case in the Parameter name (both on the Macro and where it's inserted in the Template?!).
Thats a good shout :). I would guess its going to be a parameter name? What is the functionality you are trying to acheive?
Hi guys
I have checked the alias on both the macro and in the code. Both the same.
The menu is inserted with the macrocontainer like this in my template:
The idea is that you insert the menu on each language homepage and tell it where to start and the name of the frontpage it needs to render.
What version of Umbraco are you using?
This works for me in 7.1.4
In am on 7.1.4 as well :)
When I use your code I get the name of the frontpage rendered. But not the value entered in the textbox macro parameter.
My site structure looks like this:
Danish homepage
- Subpages
Language version
- Language homepage
-- Subpages
On each new homepage the client inserts the menu with the macro container by filling out the contentpicker and the textbox with the custom name. The reason why I need the textbox parameter is because the nodes are named something like EN for english and DE for german and so on.
But in the menu I want them to enter something like Home, Start or Forside. So currentpage is not an option.
By the way, thank you very much for all the help :)
Ahhh! Well that's easy then! Your problem is using Umbraco.Content() for text fields - this is only for load an Umbraco content node (passing in the ID. To just get the text value use Model.MacroParameters["frontPage"] without that method - I'd also rename startNodeID as it's not the ID - it's the actual node content.
Hope that gets you there.
That did the trick.
Will remember that in the future, and yeah renaming to startNode sounds like a good idea :)
Thank you kind sir! :D
/Michael
is working on a reply...