Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi there
Just started on my first razor macro and ran into a problem.
The macro that needs to change some values of my button (link and text) based on the top level node ID. Not quite sure what's wrong, but I think it must be my if statements.
My code looks like this:
@{ Session["sideNavn"] = @Model.Name; int sideId = @Model.AncestorOrSelf.Id;}@{ var btnLink = ""; var btnTekst = ""; if(sideId == 1103) { btnLink = "/link1"; btnTekst = "UK text"; } else if(sideId == 1105) { btnLink = "/link2"; btnTekst = "German text"; } else { btnLink = "/link3"; btnTekst = "Danish text"; }}<form action="@btnLink" method="post"> <input id="produktBtn" class="produktBtn" type="submit" value="@btnTekst" /></form>
Any help or pointers would be great :)
/Michael
Hi Michael,
From the code your posted seems like you have a multilingual website right ? If so why not make use of culture info ?
So if its gets CultureInfo Fr, De, Dk it displays something related to it.
Hi Fuji
Thx for the reply. Yes it is multilingual, so I guess that would make more sense yes :) But its not something I have that much experience with.
I will look into it ;)
Just go get the hang of this Razor, is my code above correct, razor-wise i mean? :)
Looks like you're still using the old Razor. Might be good to read this: http://our.umbraco.org/forum/developers/razor/43007-Razor-Docs-Book#comment155105
Jeroen
Hi Jeroen
Thx for the link and making me aware of my outdated ways :)
In regards to my problem I made a quick and dirty dirty solution :P (out of time and the client does not have the need for additional languages)
The code that fixed it is:
@{ Session["sideNavn"] = @Model.Name; var sproglagNavn = @Model.AncestorOrSelf("Forside"); string btnSprog = @umbraco.library.GetDictionaryItem("Produktknap"); }@{ var btnLink = ""; var btnTekst = btnSprog; if(sproglagNavn.Name == "Home") { btnLink = "EN link"; } else if(sproglagNavn.Name == "Start") { btnLink = "DE link"; } else { btnLink = "DK link"; }}<form action="@btnLink" method="post"> <input id="produktBtn" class="produktBtn" type="submit" value="@btnTekst" /></form>
In case it might help someone or at the very least just to mark it as resolved :)
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Changing values based on ID
Hi there
Just started on my first razor macro and ran into a problem.
The macro that needs to change some values of my button (link and text) based on the top level node ID. Not quite sure what's wrong, but I think it must be my if statements.
My code looks like this:
Any help or pointers would be great :)
/Michael
Hi Michael,
From the code your posted seems like you have a multilingual website right ? If so why not make use of culture info ?
So if its gets CultureInfo Fr, De, Dk it displays something related to it.
Hi Fuji
Thx for the reply. Yes it is multilingual, so I guess that would make more sense yes :) But its not something I have that much experience with.
I will look into it ;)
Just go get the hang of this Razor, is my code above correct, razor-wise i mean? :)
/Michael
Looks like you're still using the old Razor. Might be good to read this: http://our.umbraco.org/forum/developers/razor/43007-Razor-Docs-Book#comment155105
Jeroen
Hi Jeroen
Thx for the link and making me aware of my outdated ways :)
In regards to my problem I made a quick and dirty dirty solution :P (out of time and the client does not have the need for additional languages)
The code that fixed it is:
In case it might help someone or at the very least just to mark it as resolved :)
/Michael
is working on a reply...