1

I develop a website on Umbraco CMS for one year already.

I have a Search code which i take from old website to new one every time for year without any problem.

In this case I download Umbraco 7.3.1 and now when i try to check if content Has Property i'm getting FALSE even if the property exist.

Can someone please explain where is my mistake or how to solve it on the new version of Umbraco?

Example function:

public void GlobalSearch(DynamicPublishedContent content, string field, string searchTerm, StringBuilder sb)
{
        try
        {
            if (content.HasProperty(field)) // Return always NULL!!! even the "Name" field
            {
                if (!string.IsNullOrEmpty(content.GetPropertyValue(field).ToString()))
                {
                    SpecifyPageSearch(content, field, searchTerm, sb);
                }
            }

        }
        catch (Exception ex)
        {
            return;
        }
}

Thanks in advance.

Marko Jovanov
  • 418
  • 10
  • 25
Idoshin
  • 363
  • 2
  • 17
  • It should return a boolean, so NULL sounds very unlikely. The DynamicPublishedContent.HasProperty method hasn't changed in about two years, so it sounds very strange that something should have changed in the last year :-s – Jannik Anker Nov 25 '15 at 13:42
  • @JannikAnker, You right, I change the answer from "null" to "false", I don't know why i wrote null... anyway, Do you have something in your mind which can help me to solve it? – Idoshin Nov 25 '15 at 13:46
  • Not sure, no. When I try using .HasProperty in a plain 7.3.1 installation, it works perfectly fine. Are you sure that your "content" object is correct? You can also check if the content.Properties collection has anything in it. – Jannik Anker Nov 25 '15 at 14:06
  • @JannikAnker, I'm sure :( I checked the properties by debug, All of them exist there but the Boolean return false even so. – Idoshin Nov 25 '15 at 14:22
  • Okay :-s The internal implementation of HasProperty is "return content.ContentType.GetPropertyType(alias) != null", does that also always return false for you? – Jannik Anker Nov 25 '15 at 14:25
  • @JannikAnker Yep. return false. – Idoshin Nov 25 '15 at 14:37
  • Then I have no idea, sorry :-s – Jannik Anker Nov 25 '15 at 14:38
  • @JannikAnker Thanks anyway my dear . – Idoshin Nov 25 '15 at 14:49

1 Answers1

0

Have you re-indexed your content. Go to Developer section and the Examine Management tab. Hit Rebuild for the internal index. Then do a Republish Entire Site.

wingyip
  • 3,465
  • 2
  • 34
  • 52