Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Christian Schmidt 10 posts 51 karma points
    Dec 14, 2020 @ 12:12
    Christian Schmidt
    0

    Using content templates gives problems in search

    Hi all,

    We have a client that uses content templates to create all of their newsposts, however we have encountered an issue with this. (same issue if they try to copy the content instead).

    Steps:

    1. Create new 'newsnode' from a content template.
    2. Populate with new data
    3. Save and publish
    4. Search for value in a textarea, which is present on the content template.
    5. The new node will now appear in the results, even though the textarea on this node, doesn't have the value. This happens because Node.GetPropertyValue("propertyName") is returning the value from the content template, and not the value from the new node.

    This can be fixed temporarily by publishing the new node, but will re occur again later on.

    Code used to search for nodes:

         List<IPublishedContent> newsResult = Umbraco.TypedContentAtRoot().First()
                .Descendants("news")
                .Where(y => y.GetPropertyValue<DateTime>("newsDate") <= this.now)
                .Where(x => x.Name.ToLower().Contains(search.ToLower()))
                .OrderByDescending(x => x.GetPropertyValue<DateTime>("newsDate"))
                .ThenBy(x => x.CreateDate)
                .ToList();
    

    Does anyone have any idea why this is happening?

Please Sign in or register to post replies

Write your reply to:

Draft