Copied to clipboard

Flag this post as spam?

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


  • Gayathri 55 posts 175 karma points
    Nov 20, 2020 @ 01:29
    Gayathri
    0

    Search content based on Parent node id or the current id of the page

    Hi All,

    I would like to implement a search functionality not the entire site search but the search contents based on the node id .

    for example the below is search code

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    
     @{
        var searchQuery = Request.QueryString["query"];
    
        if (!string.IsNullOrEmpty(searchQuery))    
        {
            <div class="searchresults">
                <p class="intro-para">Your search results for <strong>"@searchQuery"</strong></p>
                <ul>
                    @foreach (var result in Umbraco.Search(searchQuery))
                    {
                        if([email protected]){
                            <li>
                                <a class="heading1 inline-link" href="@result.Url">@result.Name</a>
                                <div  class="heading2">Created Date : @result.CreateDate.ToLongDateString()</div>
                                <div  class="heading2">Updated Date : @result.updateDate.ToLongDateString()</div>
                            </li>
                        }
                    }
                </ul>
            </div>
         }
    } 
    

    from the above Umbraco.Search(searchQuery) this will search the entire website inside content.

    is there any way i can search like this belwo

    Umbraco.Search(searchQuery , "Nodeid")
    

    for example

     Umbraco.Search("home loans", "1011")
    

    like this ?

  • Steve Morgan 1349 posts 4458 karma points c-trib
    Nov 20, 2020 @ 07:39
    Steve Morgan
    0

    Hi,

    I think you want to look at Examine.

    There are umpteen tutorials out there but it will quickly let you do what you want:

    https://our.umbraco.com/documentation/reference/searching/Examine/quick-start/#search-children-of-a-specific-node

    It's not as simple as Umbraco.Search but, as usual, Paul Seal has done a nice intro for you here: https://www.youtube.com/watch?v=B9NeqMN9jIw

  • Gayathri 55 posts 175 karma points
    Nov 26, 2020 @ 02:08
    Gayathri
    0

    Hi Steve,

    I would like to get it achieve by using Umbraco.Search("home loans", "1011")

    Like this :(

    Or similar like this with the same

Please Sign in or register to post replies

Write your reply to:

Draft