We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40088
    • 708 Posts
    I have a blog running fine with the current Articles add-on using Revo 2.2.6.

    I duplicated the Articles sample templates so I could customize them by removing the search form. No problems, but now I would like to add the blog search feature back again so I copied the default search form code from the 'sample.ArticlesContainerTemplate' and pasted it into the modified template.

    <form id="quick-search" action="search-results.html" method="get">
    <p>
      <label for="qsearch">Search:</label>
      <input class="tbox" id="qsearch" type="text" name="search" value="" title="Start typing and hit ENTER" />
      <input class="btn" alt="Search" type="image" title="Search" src="[[++articles.assets_url:default=`assets/components/articles/`]]themes/default/images/search.gif" />
    </p>
    </form>


    I also have a 'search-results.html' Resource but when I do a test search I get a 404; the 'search-results.html' apparently isn't being found, unless there's something else wrong.

    Thanks
      Todd
      • 22840
      • 1,572 Posts
      First thing would be to make sure your result page isn't cached and make sure you have cleared the cache before doing a search, also make sure the pages are published. that said I don't have a lot of experience with Articles so I may be way off.
        • 42562
        • 1,145 Posts
        Under what container, if any, did you create the search-results.html ?
        Check the address bar of the 404 page that the form is producing...
        is it www.yoursite.com/blog/search-results.html
        or www.yoursite.com/search-results.html ?


        <form id="quick-search" action="/blog/search-results.html" method="get">
        Just make sure that the form is looking for the resource in the right place.
        If all is matching up correctly, when you search for something you should see a blank search-results.html not a 404 message.

        Note, that search form is pretty dead, unless I am grievously mistaken, it is, as you will notice, a mere sample!
        You'll need an Addon, simplesearch or ajaxsearch. Something viable!
          TinymceWrapper: Complete back/frontend content solution.
          Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
          5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
          • 40088
          • 708 Posts
          Quote from: donshakespeare at Jan 30, 2013, 09:07 AM
          Under what container, if any, did you create the search-results.html ?
          The 'web' or root.

          Check the address bar of the 404 page that the form is producing...
          is it www.yoursite.com/blog/search-results.html
          or www.yoursite.com/search-results.html ?
          The latter.

          Note, that search form is pretty dead, unless I am grievously mistaken, it is, as you will notice, a mere sample!
          You'll need an Addon, simplesearch or ajaxsearch. Something viable!</form>

          Ah yes, having poked around some more I see this is indeed the case. My problem is I don't know how to hook another add-on (SimpleSearch etc.) into the sample search code. What I ended up doing was removing the sample code again and using SimpleSearch instead on the blog templates only, the rest of site doesn't require a search function. It works fine though my only regret is that I was hoping to restrict the search results to blog content only but as it stands now the entire site gets searched. Not a deal-breaker, just not what I set out to do.

          Thanks
            Todd
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            You can restrict the scope of the search using the &ids and &idType properties.

            ids - A comma-separated list of IDs to restrict the search to.
            idType - The type of restriction for the ids parameter. If 'parents', will add all the children of the IDs in the ids parameter to the search. If 'documents', will only use the specified IDs in the search.

            Replacing the sample search block with a search snippet is the correct way to do it; then you can adjust the search form tpl to match the look of the sample if you like.
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 42562
              • 1,145 Posts
              http://rtfm.modx.com/display/ADDON/SimpleSearch.SimpleSearch

              I don't want to search my entire site.
              I throw my blog entries under containers (i.e another document) if they are not already under containers. If you are using Articles Addon, your blog content is grouped under containers already
              ==> /blog2/my-first-entry.html (blog2 is a container, a parent!)
              [[!SimpleSearchForm]]
              [[!SimpleSearch? &depth=`50` &ids=`209,259` &idType=`parents` &hideMenu=`1` &processTVs=`0` &highlightTag=`strong` &tpl=`tpl`]]
              //209,259 are the resource ids of my blog containers/parents. The search will involve only the children pages

              If you run into problems using the &ids and &idType, report it to https://github.com/splittingred/SimpleSearch/issues?page=1&state=closed apparently it has some issues.

              If you like so much the presentation of the sample.template search form, you could edit the html of the simplesearch form...look for the simplesearch category folder under chunks, then simpleSearchTpl. Make sure you back it up before you blow it apart smiley
                TinymceWrapper: Complete back/frontend content solution.
                Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
                5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
                • 42562
                • 1,145 Posts
                Yea, Susan already posted while I was typing...follow what she says...
                  TinymceWrapper: Complete back/frontend content solution.
                  Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
                  5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  Don't edit any of the default Articles templates and chunks. Copy them with different names and specify your copies in the main Articles configuration. If you edit the existing elements, they will be overwritten if you upgrade Articles at some point in the future.
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org
                    • 40088
                    • 708 Posts
                    Here's my original working SimpleSearch code before I tried the above instructions to restrict the search results:

                    [[!SimpleSearchForm? &landing=`36` &tpl=`ArticlesSearch`]]


                    Using the suggestions above modified for my needs:

                    [[!SimpleSearchForm]]
                    [[!SimpleSearch? &landing=`36` &ids=`17` &idType=`parents` &depth=`50` &showExtract=`0` &tpl=`ArticlesSearch`]]


                    The search results are now restricted to the blog container and it shows the results count, but not the actual results. Also, I'm not being redirected the 'search results' page like I was previously, instead the results are displayed on the same page the search was done on. [ed. note: todd.b last edited this post 13 years, 8 months ago.]
                      Todd
                      • 42562
                      • 1,145 Posts
                      Place this form code wherever you want in the template or resource
                      [[!SimpleSearchForm? &tpl=`simpleSearchTpl` &landing=`36`]]
                      //landing-page is a SimpleSearchForm property
                      //36 is the id of search-results.html

                      Then place this in the search-results.html resource
                      [[!SimpleSearch? &ids=`17` &idType=`parents` &depth=`50` &showExtract=`0` &tpl=`ArticlesSearch`]]
                      //why &showExtract=`0` ? unless you don't want
                      //resources under Articles Container are hidden by default. try &hideMenu=`2`
                      
                      //the ArticlesSearch chunk here should look something like :
                      <div class="sisea-result">
                          <h1>[[+idx]]. <a href="[[+link:is=``:then=`[[~[[+id]]]]`:else=`[[+link]]`]]" title="[[+longtitle]]">[[+pagetitle]]</a></h1>
                          <div class="extract"><p>[[+extract]]</p></div>
                      </div>
                        TinymceWrapper: Complete back/frontend content solution.
                        Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
                        5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.