We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 43010
    • 7 Posts
    I have a page in the frontend which is a container resource created out of its children's content with a getResources call. The parent resource doesn't have its own content and is accessible by the users navigating the website while its children aren't. However, if they make a search for a keyword that can be found in one of those children resources, the container resource doesn't show up in the search results while that specific child does. It's easy to exclude those children from the search results, but how can I make the parent show up? Any ideas?

    I'm using AdvSearch 1.0.1 on Rev 2.2.4
      • 43010
      • 7 Posts
      Is Lucene the way to go in this case? Is it doable at least?
        • 5811
        • 1,717 Posts
        Don't exclude the children documents. Simply change the link inside AdvSearchResult template. To get a link to the parent inside each search result, do as follow:

        1/ create a specific template e.g: advsearchParentResult with the following content:
        <div class="advsea-result">
            <h3>[[+idx]]. <a href="[[~[[+parent]]]]" title="[[+longtitle]]">[[+pagetitle]]</a></h3>
            <div>[[+extracts]]</div>
        </div>


        2/ And in order to get the parent id of each result add the following parameter inside your AdvSearch call:

        &fields=`pagetitle,longtitle,parent,content`


        By adding parent in the fields list (not present by default) you could use
        href="[[~[[+parent]]]]"
        inside the search result template.

        By doing, you get all the children as search results but the target link is the container document.
          • 43010
          • 7 Posts
          Hi coroico, thanks for your reply. While it didn't solved my problem, I did learn something new and valuable though.

          Creating the specific search result template you've suggested will make all search results link to their parent resources, right? If so, it won't do the job in my case.
          Anyway, I've already created a special template for those child resources, only containing a Redirectoid snippet call inside, so that anytime you try to access one of them, it redirects you to its parent:
          [[Redirectoid? &id=`[[*parent]]`]]


          This works great if I'm getting one result only from that specific parent resource children per search, but when I'm getting more than one, things get ugly because it's like having duplicate search results. This is what I'm trying to avoid and I thought AdvSearch is able to search inside resources' content field even if that content is actually generated by a snippet. Is AdvSearch able to do this or did I misunderstand? If not, I'll just use jQuery to eliminate duplicate search results from the page even though it's a bit of an ugly hack.