Im trying to write an if statement with an umbraco template and based on the test i want to render different things.
Im trying to test whether the current logged in member is an owner of a venue (alias = venueOwner) and if they are show edit venue user control but if they are not just show venue info.
I keep getting syntax errors can someone advise me on the best way to test whether the current logged in member matches a property?
eg
<% if (Membership.GetUser() != null ) { %>
<!--if member is logged in and is the venue owner, show the update venue form-->
<%} %>
<%else {%>
<!--else show the full venue display here for end users and people who dont own the venue-->
<%} %>
The syntax above works if a member is logged in but if a logged in member views a venue they don't own then still no venue info is displayed.
i need a test that says if a member is the venue owner then show them the edit form otherwise for non members and members who dont own the venue just show the venue info. However im unsure of the sytax and keep getting errors :(
Ive tried
<% if (Membership.GetUser() != (umbraco.library.GetItem("venueOwner"))) { %>
Those statements worked for ok for when a user is logged in but it errors when a user is not logged in because it is looking for the current member so i need to test if member.getUser is null as well.
is it something like this but this gives me syntax error?
If statement within template
Hi all,
Im trying to write an if statement with an umbraco template and based on the test i want to render different things.
Im trying to test whether the current logged in member is an owner of a venue (alias = venueOwner) and if they are show edit venue user control but if they are not just show venue info.
I keep getting syntax errors can someone advise me on the best way to test whether the current logged in member matches a property?
eg
The syntax above works if a member is logged in but if a logged in member views a venue they don't own then still no venue info is displayed.
i need a test that says if a member is the venue owner then show them the edit form otherwise for non members and members who dont own the venue just show the venue info. However im unsure of the sytax and keep getting errors :(
Ive tried <% if (Membership.GetUser() != (umbraco.library.GetItem("venueOwner"))) { %>
Any help would be a bonus :)
Cheers
Hello,
It might be easier to convert this code to a Razor macro because it's more flexible.
Jeroen
Hi Jeroen
Thanks for the reply mate. TBH ive not done much with Razor as of yet so just looking for a quick fix this way for the time being (if I can).
Ive also tried this but still getting syntax error im obviously missing something here lol
CS0019: Operator '!=' cannot be applied to operands of type 'System.Web.Security.MembershipUser' and 'umbraco.presentation.nodeFactory.Property'
Cheers
Paul
If you want a quick fix this might work:
Jeroen
Thanks again for your reply but still no luck I have the following error :(
CS0019: Operator '!=' cannot be applied to operands of type 'System.Web.Security.MembershipUser' and 'string'
Thanks
Paul
I think this might be it:
Jeroen
Yeah that worked jeroen but i need the id of the member becuase the value being stored in the venue owner alias is an integer.
We are nearly there tho ha
Paul
You could try the following than ;-)
Or
Jeroen
Hi Jeroen,
Those statements worked for ok for when a user is logged in but it errors when a user is not logged in because it is looking for the current member so i need to test if member.getUser is null as well.
is it something like this but this gives me syntax error?
<% if ((Membership.GetUser() != null) && (umbraco.cms.businesslogic.member.Member.GetCurrentMember().Id.ToString() != (umbraco.presentation.nodeFactory.Node.GetCurrent().GetProperty("venueOwner").Value) )) { %>
Paul
This did the trick jeroen
Thanks for you help and time mate! Very much apreciated!
Paul :)
Ok I thought a member was always logged on. This check should do the trick:
This code first checks if the member is logged on and after that if the member id is the same as the id stored in the venueOwner property.
Jeroen
Looks like you already found out yourself. Glad I could help :-).
Jeroen
It was probably my poor explanation ;).
The help you gave was brilliant and without it I would of struggled, so thank you very much.
Paul
is working on a reply...