Coded something up in Couch in an interesting way? Have a snippet or shortcode to share? Post it here for the community to benefit.
61 posts Page 4 of 7
Previous 1, 2, 3, 4, 5, 6, 7 Next
@Jiwa,
We can put the form showing the dropdowns (in 'search.htm' snippet) in one template and set the 'action' parameter of that form to point to the second template that will show the results.
<cms:form name="quicksearch" id="quicksearch" anchor='0' action="second.php">

The second template showing the results will, however, still need the same form to be shown just above the <cms:pages> block doing the listing. So we cannot totally disassociate the two components.

Hope it helps.
Thank you, KK!! This is exactly what I need! :D
It works great! Every hour of work with Couch - it's magic.
Neat solution - thanks KK ;)
My question is - can we do all this more modern?
Now there are many forms of search without button "Start Searching!"
Their action begins after the customer chooses a parameter.
Something like the attached photo.

Maybe it's mandatory Ajax, but how to do here?
Maybe it will help KK ;)
Thanks in advance to all

Attachments

@orbital, this is done with some simple JS. There are samples on forum, but google will show faster :) You need to 'submit' form when any checkbox/dropdown selected/deselected.
Something like
<cms:form ><cms:input {here is your input} onchange="this.form.submit()"><cms:input type='submit' name='submit' /></cms:form>

When you manage it to work, please post the solution details you chose.
Thank you trendoman ;)
Here workable solution without button "Start Searching!"

Code: Select all
<div id="quick-search" style="float:right; margin-right:50px;">

   <cms:form name="quicksearch" id="quicksearch" anchor='0'>
      <cms:if k_success >
         
         <cms:if frm_locality!='-' >
            <cms:set my_search_str="<cms:concat my_search_str ' | my_locality==' frm_locality />"  scope='global'/>
         </cms:if>
         
         <cms:if frm_property_type!='-' >
            <cms:set my_search_str="<cms:concat my_search_str ' | my_property_type==' frm_property_type />"  scope='global'/>
         </cms:if>
         
         <cms:if frm_min_price!='-' >
            <cms:set my_search_str="<cms:concat my_search_str ' | my_price>=' frm_min_price />"  scope='global'/>
         </cms:if>   
         
         <cms:if frm_max_price!='-' >
            <cms:set my_search_str="<cms:concat my_search_str ' | my_price<=' frm_max_price />"  scope='global'/>
         </cms:if>         

         <cms:if frm_min_bedrooms!='-' >
            <cms:set my_search_str="<cms:concat my_search_str ' | my_num_bedrooms>=' frm_min_bedrooms />"  scope='global'/>
         </cms:if>

         <cms:if frm_min_bathrooms!='-' >
            <cms:set my_search_str="<cms:concat my_search_str ' | my_num_bathrooms>=' frm_min_bathrooms />"  scope='global'/>
         </cms:if>

         <cms:if frm_min_sqft!='-' >
            <cms:set my_search_str="<cms:concat my_search_str ' | my_plot_area>=' frm_min_sqft />"  scope='global'/>
         </cms:if>
         
      </cms:if>
      
      <div>
         <label>Locality</label>
         <cms:input onchange="this.form.submit()" type="dropdown"
               opt_values='No Preference=- | Перник  | Севлиево | Дупница | София'
               opt_selected='-'
               name="locality" id="locality" />
      </div>
      <div>
         <label>Property Type</label>
         <cms:input onchange="this.form.submit()" type="dropdown"
               opt_values='No Preference=- | Residential  | Commercial | Rental'
               opt_selected='No Preference'
               name="property_type" id="property_type" />
      </div>
      <div>
         <label>Minimum Price</label>
         <cms:input onchange="this.form.submit()" type="dropdown"
               opt_values='
               No Minimum=- | Rs. 100,000=100000  | Rs. 125,000=125000 | Rs. 150,000=150000
               | Rs. 175,000 = 175000 | Rs. 200,000=200000  | Rs. 225,000=225000 | Rs. 250,000=250000
               | Rs. 275,000 = 275000 | Rs. 300,000=300000  | Rs. 325,000=325000 | Rs. 350,000=350000
               | Rs. 375,000 = 375000 | Rs. 400,000=400000  | Rs. 425,000=425000 | Rs. 450,000=450000
               | Rs. 475,000 = 475000 | Rs. 500,000=500000  | Rs. 600,000=600000 | Rs. 700,000=700000
               | Rs. 800,000 = 800000 | Rs. 900,000=900000  | Rs. 10,00,000=1000000 | Rs. 12,50,000=1250000
               | Rs. 15,00,000 = 1500000 | Rs. 17,50,000=1750000  | Rs. 20,00,000=2000000 | Rs. 22,50,000=2250000
               | Rs. 25,00,000 = 2500000 | Rs. 27,50,000=2750000  | Rs. 30,00,000=3000000 | Rs. 32,50,000=3250000
               | Rs. 35,00,000 = 3500000 | Rs. 37,50,000=3750000  | Rs. 40,00,000=4000000 | Rs. 45,00,000=4500000
               | Rs. 50,00,000 = 5000000 | Rs. 55,00,000=5500000  | Rs. 60,00,000=6000000 | Rs. 65,00,000=6500000
               | Rs. 70,00,000 = 7000000 | Rs. 75,00,000=7500000  | Rs. 80,00,000=8000000 | Rs. 85,00,000=8500000
               | Rs. 90,00,000 = 9000000 | Rs. 95,00,000=9500000  | Rs. 100,00,000=10000000
               '
               opt_selected='-'
               name="min_price" id="min_price" />
      </div>
      <div>
         <label>Maximum Price</label>
         <cms:input onchange="this.form.submit()" type="dropdown"
               opt_values='
               No Maximum = - | Rs. 100,000=100000  | Rs. 125,000=125000 | Rs. 150,000=150000
               | Rs. 175,000 = 175000 | Rs. 200,000=200000  | Rs. 225,000=225000 | Rs. 250,000=250000
               | Rs. 275,000 = 275000 | Rs. 300,000=300000  | Rs. 325,000=325000 | Rs. 350,000=350000
               | Rs. 375,000 = 375000 | Rs. 400,000=400000  | Rs. 425,000=425000 | Rs. 450,000=450000
               | Rs. 475,000 = 475000 | Rs. 500,000=500000  | Rs. 600,000=600000 | Rs. 700,000=700000
               | Rs. 800,000 = 800000 | Rs. 900,000=900000  | Rs. 10,00,000=1000000 | Rs. 12,50,000=1250000
               | Rs. 15,00,000 = 1500000 | Rs. 17,50,000=1750000  | Rs. 20,00,000=2000000 | Rs. 22,50,000=2250000
               | Rs. 25,00,000 = 2500000 | Rs. 27,50,000=2750000  | Rs. 30,00,000=3000000 | Rs. 32,50,000=3250000
               | Rs. 35,00,000 = 3500000 | Rs. 37,50,000=3750000  | Rs. 40,00,000=4000000 | Rs. 45,00,000=4500000
               | Rs. 50,00,000 = 5000000 | Rs. 55,00,000=5500000  | Rs. 60,00,000=6000000 | Rs. 65,00,000=6500000
               | Rs. 70,00,000 = 7000000 | Rs. 75,00,000=7500000  | Rs. 80,00,000=8000000 | Rs. 85,00,000=8500000
               | Rs. 90,00,000 = 9000000 | Rs. 95,00,000=9500000  | Rs. 100,00,000=10000000
               '
               opt_selected='-'
               name="max_price" id="max_price" />

      </div>
      <div>
         <label>Bedrooms </label>
         <cms:input onchange="this.form.submit()" type="dropdown"
               opt_values='No Preference=- | 1 Bed=1  | 2 Bed=2 | 3 Bed=3
               | 4 Bed=4  | 5 Bed=5 | 6 Bed=6 | 7 Bed=7
               '
               opt_selected='No Preference'
               name="min_bedrooms" id="min_bedrooms" />
          (minimum)      
      </div>
      <div>
         <label>Bathrooms</label>
         <cms:input onchange="this.form.submit()" type="dropdown"
               opt_values='No Preference=- | 1  | 2 | 3
               | 4  | 5 | 6 | 7 | 8
               '
               opt_selected='No Preference'
               name="min_bathrooms" id="min_bathrooms" />   
         (minimum)      
      </div>
      <div>
         <label>Квадратура</label>
         <cms:input onchange="this.form.submit()" type="dropdown"
               opt_values='
               No Preference = - | 500 sq. ft=500  | 1,000 sq. ft=1000 | 1,500 sq. ft=1500
               | 2,000 sq. ft=2000  | 2,500 sq. ft=2500 | 3,000 sq. ft=3000 | 3,500 sq. ft=3500
               | 4,000 sq. ft=4000  | 4,500 sq. ft=4500 | 5,000 sq. ft=5000 | 5,500 sq. ft=5500
               | 6,000 sq. ft=6000  | 6,500 sq. ft=6500 | 7,000 sq. ft=7000 | 7,500 sq. ft=7500
               | 8,000 sq. ft=8000  | 8,500 sq. ft=8500 | 9,000 sq. ft=9000 | 9,500 sq. ft=9500
               | 10,500 sq. ft=10500
               '
               opt_selected='-'
               name="min_sqft" id="min_sqft" />
         (minimum)
      </div>   

   </cms:form>

</div>
<script>$('#quicksearch').change(function(){$(this).closest('form').trigger('submit');});</script>   


Trendoman I have two small questions:
1. How do I reset button (or reset at refresh the page)?
2. I can do orderby (in pages tag) changed by frontend user without Notejam?

Regards
Trendoman I have two small questions:
1. How do I reset button (or reset at refresh the page)?
2. I can do orderby (in pages tag) changed by frontend user without Notejam?

Regards

Hi, probably you might try to refresh the page in k_success block: <cms:redirect k_page_link />. It should clear the inputs.

Next, sorting in pages depends on what you need to change. In all the cases, it would be something like orderby='page_name' which can be replaced by your variable, set before cms:pages and used inside cms:pages parameters like this: orderby=my_orderby. You can use in orderby *any* of your custom editables.

Taking example from the doc:
Code: Select all
<cms:pages masterpage='blog.php' orderby='my_blog_author'></cms:pages>

And modifying it to use with user choice
Code: Select all
<cms:form name='form' >
    <cms:if k_success >
         <cms:set my_orderby=frm_my_orderby scope='global' />
    </cms:if>
<cms:input type="radio" name='my_orderby' opt_values=' name=page_name | date=publish_date  | random | author = my_blog_author' opt_selected='page_name' onchange="this.form.submit()"  />
</cms:form>
<cms:pages masterpage='blog.php' orderby=my_orderby></cms:pages>


Let me know if any doubts.

Below is completely working playable form (change masterpage to your real clonable template).
Code: Select all

  <cms:form name='form' >
    <cms:if k_success >
         <cms:set my_orderby=frm_my_orderby scope='global' />
         <cms:set my_order=frm_my_order scope='global' />
    </cms:if>
<cms:input onchange="this.form.submit()" type="radio" name='my_orderby' opt_values=' name=page_name | date=publish_date  | random ' opt_selected='page_name' />
  <cms:if my_orderby ne 'random' >
     <cms:input onchange="this.form.submit()" type="radio" name='my_order' opt_values=' Asc=asc | Desc=desc ' opt_selected='asc' />
  </cms:if>   
</cms:form>
<cms:pages masterpage='blog.php' orderby=my_orderby order=my_order ><cms:show k_page_title /><br></cms:pages>

Thank you trendoman ;)

But your solution:
"probably you might try to refresh the page in k_success block: <cms:redirect k_page_link />. It should clear the inputs." to me does not work.
I use the following simple solution:
Code: Select all
<a href="<cms:show k_page_link />"><button type="button">Reset filters</button></a>


Next, sorting in pages work fine, Thank you!
Greetings! I have another question: Is it possible to choose a folder to search in, or select a folder for later redirect to it (maybe with action="")? For example, I start to search among the pages of the catalog.php, being on the index.php, but want to search only in a specific template folder directory chosen by. Thank you!
@Jiwa, the <cms:pages> tag accepts a 'folder' parameter (http://docs.couchcms.com/tags-reference ... tml#folder) - you can set that to the name of the folder you need to search in.

If that folder name is configurable, use the technique described in this thread to create a dropdown and then use its submitted value to set the mentioned parameter.

Hope this helps.
@KK, It really helped!! Thank you!! Sorry for the obvious question, I should have known)) :D
Previous 1, 2, 3, 4, 5, 6, 7 Next
61 posts Page 4 of 7
cron