True/False sometimes comes back as "0" or "1" rather than bool
This is a really weird problem. I have a master DocType called ContentMaster that has a True/False property on it called hideFromSitemap. I then have a number of DocTypes that inherit from ContentMaster, such as Article, Folder, ContactPage etc. Obviously all of these DocTypes also have the hideFromSitemap True/False property on them.
I am then listing all the pages in the site and checking outputing botht he value and type of hideFromSitemap.
What I find is something like this:
Gallery False System.Boolean
Photos False System.Boolean
Demo Gallery False System.Boolean
Footer 1 System.String
Another Gallery True System.Boolean
Videos False System.Boolean
Village Videos False System.Boolean
The Gardens False System.Boolean
About Us False System.Boolean
FAQ True System.Boolean
Note the page called Footer. This is returning "1" and is of type String whereas every other node is returning as a proper boolean. Remember, the Footer page is based on a DocType that inherits from the same ContentMaster DocType that has hideFromSitemap defined on it as a True/False. There is no difference at all. Doesn't make sense!
I've tried re-publishing the page, re-saving the doctypes but it makes no difference, it still comes back as a String. I've checked the Raw XML and the XML is identical for all hideFromSitemap properties regardless of DocType eg.
<hideFromSitemap>0</hideFromSitemap>
or
<hideFromSitemap>1</hideFromSitemap>
So why is it coming back as a string and not a bool for the Folder DocType ????
Wow, still doing this in 4.11.6 ? I'd report it as a bug, but I've not found any way to reproduce this. Be interesting to see if there's any reason why this might happen.
True/False sometimes comes back as "0" or "1" rather than bool
This is a really weird problem. I have a master DocType called ContentMaster that has a True/False property on it called hideFromSitemap. I then have a number of DocTypes that inherit from ContentMaster, such as Article, Folder, ContactPage etc. Obviously all of these DocTypes also have the hideFromSitemap True/False property on them.
I am then listing all the pages in the site and checking outputing botht he value and type of hideFromSitemap.
What I find is something like this:
Note the page called Footer. This is returning "1" and is of type String whereas every other node is returning as a proper boolean. Remember, the Footer page is based on a DocType that inherits from the same ContentMaster DocType that has hideFromSitemap defined on it as a True/False. There is no difference at all. Doesn't make sense!
I've tried re-publishing the page, re-saving the doctypes but it makes no difference, it still comes back as a String. I've checked the Raw XML and the XML is identical for all hideFromSitemap properties regardless of DocType eg.
or
So why is it coming back as a string and not a bool for the Folder DocType ????
Could you post the razor you use to list the properties?
This is the entire script. It generates a Sitemap:
Note: What I wanted in my @foreach was to do this:
But now I have to use this work-around:
I have the same problem. Some nodes have 1 and 0 and others have True/False.
They all inherit this property from parent document type.
Umbraco version is 4.11.6
Wow, still doing this in 4.11.6 ? I'd report it as a bug, but I've not found any way to reproduce this. Be interesting to see if there's any reason why this might happen.
I solved my problem by making helper function which tries to parse it as bool and integer. I should probably post is as a problem.
This is still a problem in v6.0.5.
I'm having to use:
Given this is still happening I've reported it as an issue. Please vote it up!
http://issues.umbraco.org/issue/U4-2307
is working on a reply...