Copied to clipboard

Flag this post as spam?

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


  • John ben 78 posts 293 karma points
    Apr 13, 2017 @ 09:45
    John ben
    0

    adding content in Search page in Umbraco

    Hi, I want to use a search which search in my entire website i used this:

    @{ var searchQuery = Request.QueryString["query"];

        if (!string.IsNullOrEmpty(searchQuery))    
        {
            <div class="searchresults">
                <p>Your search results for <strong>@searchQuery</strong></p>
                <ul>
                    @foreach (var result in Umbraco.Search(searchQuery))
                    {
                        <li>
                            <a href="@result.Url">@result.Name</a>
                        </li>
                    }
                </ul>
            </div>
         }
    }
    

    it worked perfectly the probleme i want to see the description of each result which is represented in a richtextbox, i m not too familiar with examine

  • Sven Geusens 169 posts 881 karma points c-trib
    Apr 13, 2017 @ 10:06
    Sven Geusens
    100

    Umbraco.Search() returns a dynamic. So to get a property from it you simply do @result.PropertyName

    If you are more comfortable with IPublishedContent then use Umbraco.TypedSearch() in the same way, so you can do @result.GetPropertyValue("propertyName")

  • John ben 78 posts 293 karma points
    Apr 13, 2017 @ 10:11
    John ben
    0

    Worked fine. Thanks a lot!

Please Sign in or register to post replies

Write your reply to:

Draft