Check document type property using IsNullOrEmpty or HasValue causing error loading MacroEngine script.
Trying a test to check if my page contains an image using DAMP and if no image is selected to show a generic header image. Below is the code I'm using. Two issues. In my dev environment below works fine, in my test environment on a shared hosted account (identical umbraco setup 4.7.1) the below code fails. My second question is how would I find the error being generated as all I get on my shared hosted account is Error loading MacroEngine script (file: ) .
Just be careful...what if the editor deletes the image or crop. You might end up with ProductHeaderImage having a value...but that value is XML markup with empty nodes...which might break still.
Yeah, I tested that senario and when an editor removes the image from the DAMP control and the check for HasValue gets to the else branch so the generic-header.jpg image is displayed. Thanks for the follow up.
Did you ever get an answer to your second question? I really could use that info as well...
>>My second question is how would I find the error being generated as all I get on my shared hosted account is Error loading MacroEngine script (file: ) .
Check document type property using IsNullOrEmpty or HasValue causing error loading MacroEngine script.
Trying a test to check if my page contains an image using DAMP and if no image is selected to show a generic header image. Below is the code I'm using. Two issues. In my dev environment below works fine, in my test environment on a shared hosted account (identical umbraco setup 4.7.1) the below code fails. My second question is how would I find the error being generated as all I get on my shared hosted account is Error loading MacroEngine script (file: ) .
Below is the umbraco.config output for the blank value:
Below is the umbraco.config output for an example that contains an image value:
Thanks!
I think you need to check the property first before charging into mediaItem etc. Try:
Thanks Trevor. I took the .HasValue you suggested and used it as the basis of the check, the code below works as I would expect.
Just be careful...what if the editor deletes the image or crop. You might end up with ProductHeaderImage having a value...but that value is XML markup with empty nodes...which might break still.
Yeah, I tested that senario and when an editor removes the image from the DAMP control and the check for HasValue gets to the else branch so the generic-header.jpg image is displayed. Thanks for the follow up.
Jason,
Did you ever get an answer to your second question? I really could use that info as well...
>>My second question is how would I find the error being generated as all I get on my shared hosted account is Error loading MacroEngine script (file: ) .
is working on a reply...