@{ var page = Model.AncestorOrSelf("Category2HomePage");
if (page.contactPhone != "" && page.contactEmail != "" && page.contactPhone2 != "" && page.contactEmail2 != "") { <a class="hide_email" rel="@page.contactEmail">@page.contactPhone</a> <br /> <a class=" hide_email" rel="@page.contactEmail2">@page.contactPhone2</a> } if (page.contactPhone != "" && page.contactEmail != "" && page.contactPhone2 != "") { <a class="hide_email" rel="@page.contactEmail">@page.contactPhone</a> <br /> @page.contactPhone2 } if (page.contactEmail != "" && page.contactEmail2 != "") { <a class=" show hide_email" rel="@page.contactEmail">@page.contactEmail</a> <br /> <a class=" show hide_email" rel="@page.contactEmail2">@page.contactEmail2</a> } if (page.contactPhone != "" ) { @page.contactPhone <br /> } if (page.contactEmail != "") { <a class=" show hide_email" rel="@page.contactEmail">@page.contactEmail</a> } if (page.contactPhone2 != "" ) { @page.contactPhone2 <br /> } if (page.contactEmail2 != ""){ <a class=" show hide_email" rel="@page.contactEmail2">@page.contactEmail2</a> }
}
As I understand your code you are checking that the one of these page.contactPhone != "" && page.contactEmail != "" && page.contactPhone2 != "" && page.contactEmail2 != "" fields not are empty, if so you are going to the next if statement if (page.contactPhone != "" && page.contactEmail != "" && page.contactPhone2 != "") and so on.
The way his code is working is if the fields contactPhone and contactEmail not are empty but both contactPhon2 and contactEmail2 then you will get this out,
If the one of the contactPhone2 and contactEmail2 are empty and you have fill out all the fields then you will get them out. lets say that the contactEmail2 are empty then you will get contactPhone and contactEmail and contactPhone2
Maybe you need to adjustthe use ofbreaktagsto meet yourrequirements else could you please try explain what data you are expecting in the different scenarios
Syntax Issue
Could someone tell me why this is not saving?
Hi Steve,
What if you do something like this:
Hope this helps,
/Dennis
Thanks, but I am still receiving an error around the middle else statement.
Hi Steve,
Did you get the error when you try saving the file or on the frontend of your website?
/Dennis
Hi Steve,
What if you are trying this:
As I understand your code you are checking that the one of these page.contactPhone != "" && page.contactEmail != "" && page.contactPhone2 != "" && page.contactEmail2 != "" fields not are empty, if so you are going to the next if statement if (page.contactPhone != "" && page.contactEmail != "" && page.contactPhone2 != "") and so on.
Hope this helps,
/Dennis
I've got some of it to work, but for some reason my else isn't working.
Hi Steve,
I think I found a solution to you. I will explain it step by step, and hope it meet your needs
@inherits umbraco.MacroEngines.DynamicNodeContext
@{
var page = Model.AncestorOrSelf("Category2HomePage");
if (page.contactPhone != "" && page.contactEmail != "" && page.contactPhone2 == "" && page.contactEmail2 == "") {
<a class="hide_email" rel="@page.contactEmail">@page.contactPhone</a>
}
if (page.contactPhone2 != "" && page.contactEmail2 != "" && page.contactPhone == "" && page.contactEmail == "") {
<a class=" hide_email" rel="@page.contactEmail2">@page.contactPhone2</a>
}
else {
if (page.contactPhone != "" ) {
@page.contactPhone
<br />
}
if (page.contactEmail != "") {
<a class="show hide_email" rel="@page.contactEmail">@page.contactEmail</a>
<br />
}
if (page.contactPhone2 != "") {
@page.contactPhone2
<br />
}
if (page.contactEmail2 != "" ) {
<a class="show hide_email" rel="@page.contactEmail2">@page.contactEmail2</a>
}
}
}
The way his code is working is if the fields contactPhone and contactEmail not are empty but both contactPhon2 and contactEmail2 then you will get this out,
If the fields contactPhone and page.contactEmail are empty but both contactPhon2 and contactEmail2 fill out then you will get this out,
If the one of the contactPhone2 and contactEmail2 are empty and you have fill out all the fields then you will get them out. lets say that the contactEmail2 are empty then you will get contactPhone and contactEmail and contactPhone2
Maybe you need to adjust the use of break tags to meet your requirements else could you please try explain what data you are expecting in the different scenarios
Hope this helps,
/Dennis
is working on a reply...