We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 44231
    • 126 Posts
    How can I specify the result of the simple search

    Example:

    my first try in simple search this is the output

    Search Results

    There were no search results for the search "acid". Please try using more general terms to get more results.
    Results (513)

    1. 20040437

    2. 20040438

    I want it like this

    Search Results

    There were no search results for the search "acid". Please try using more general terms to get more results.
    Results (513)

    (brand_name here)
    content:
    category:
    date publish

    (another brand_name)
    content:
    category:
    date publish:


    Is it possible?

    thanks!
      • 29839 ☆ A M B ☆
      • 66 Posts
      have you tried to change the content and structure of the simplesearch TPL?

      default is:
      <div class="sisea-result">
          <h3>[[+idx]]. <a href="[[+link:is=``:then=`[[~[[+id]]]]`:else=`[[+link]]`]]" title="[[+longtitle]]">[[+pagetitle]]</a></h3>
          <div class="extract"><p>[[+extract]]</p></div>
      </div


      You can use the following for the published on:

      [[+publishedon:strtotime:date=`%a %b %e, %Y`]]

      [ed. note: thijsvandamme last edited this post 13 years, 2 months ago.]
        • 44231
        • 126 Posts
        I read it but I dont know where to start or what part is going to be change?
          • 9207 ☆ A M B ☆
          • 2,475 Posts
          I'm confused by your question -- "can I specify the result of the simple search?" -- do you want to change the format? Or the actual result?

          If you want to change the format, you need to specify a &tpl argument in your Snippet call, e.g. create a Chunk named "myChunk"

          <div class="sisea-result">
              <h3>[[+idx]]. <a href="[[~[[+id]]]]" title="[[+longtitle]]">[[+pagetitle]]</a></h3>
              <div class="extract"><p>[[+extract]]</p></div>
          </div>
          


          And then reference it in your Snippet call:

          [[!SimpleSearch? &tpl=`myChunk`]]


          That's just an example. The other arguments available are here: http://rtfm.modx.com/display/ADDON/SimpleSearch.SimpleSearch

          But without knowing how you've structured your data, it's impossible to give you a specific answer. Your example there has "category" and "brand_name" -- are you making TVs for those? Or are you structuring your pages so the parent folder is a category? There are many different ways you could do this.

          It doesn't look like it provides a count of how many records were matched in the search -- that would take a separate database query, so I can understand why it's omitted.

          Bottom line is that searching is subtly complicated, and unless you have a really good reason for it, it's much easier to leave it to Google. (Usually people ignore that advice, then waste many hours of their lives, then often they come back to Google... that's just my observation).
            • 44231
            • 126 Posts
            Im sorry if I confused you with my question

            I want to change the result it self

            when I do a search using simple search with posthook

            it give me a result of

            1.(brand_name)
            2.(another brand_name)
            3.(also another brand_name)

            I want it to be more detailed
            add more data that support the results coming from my database
              • 29839 ☆ A M B ☆
              • 66 Posts
              As of right now you only get
              1. 20040437

              2. 20040438
              right?

              That is because the chunk that is being used to format your search results is:

              <div class="sisea-result">
                  <h3>[[+idx]]. <a href="[[+link:is=``:then=`[[~[[+id]]]]`:else=`[[+link]]`]]" title="[[+longtitle]]">[[+pagetitle]]</a></h3>
                  <div class="extract"><p>[[+extract]]</p></div>
              </div


              I suggest you make a chunk called "myspecialsearchresults" or however you want to call it...

              Edit the code to match the output of a single result:

              <li class="sisea-result">
              <h3>[[+idx]]. <a href="[[+link:is=``:then=`[[~[[+id]]]]`:else=`[[+link]]`]]" title="[[+longtitle]]">[[+pagetitle]]</a></h3>
               <p>[[+introtext:ellipsis=`100` default=`[[+content:ellipsis=`100`]]`]]<p>
               <p>Category (We dont know how you configured yours)</p>
               <p>[[+publishedon:strtotime:date=`%a %b %e, %Y`]]</p>
              </li>
              


              You can use whatever html formatting you like...

              then on your search results page put the following:


              [[!SimpleSearch? &tpl=`myspecialsearchresults`]]




                • 44231
                • 126 Posts
                ok thank you very much I will surely try this thing

                :D
                  • 9207 ☆ A M B ☆
                  • 2,475 Posts
                  You changed this with a post hook? Then you need to clarify what you did even more because now you've modified the default behavior.