Coded something up in Couch in an interesting way? Have a snippet or shortcode to share? Post it here for the community to benefit.
59 posts Page 2 of 6
Previous 1, 2, 3, 4, 5, 6 Next
@simmons,
We'll have to fall back upon raw PHP for that.

Please try the following to create the string of names -
Code: Select all
<cms:pages masterpage='gallery.php'>
  <cms:php>
        global $my_arr, $all_locality, $CTX;
        if( !is_array($my_arr) ) $my_arr=array();
       
        $locality = $CTX->get('locality');
        if( !in_array($locality, $my_arr) ){
            $my_arr[]=$locality;
            $all_locality .= '|' . $locality;
        }
    </cms:php>
</cms:pages>

And the following to use the string created above to create a dropdown
Code: Select all
<cms:input type="dropdown" name='locality' id='locality' opt_values="Any=- <cms:php>global $all_locality; echo $all_locality; </cms:php>" />

Hope this helps. Do let us know.
Thanks.
that method worked flawlessly! thank you once again.

unfortunately im still having that problem when when i search for certain property from the search area, ALL properties show up as results and the my_search_str (for debugging) still displays nothing.

I PM'd the files already
I'm not primitive, My time machine just malfunctioned in your era.
SimonRLM and patrickvibes, how did this solution work out for u? Am still strugglin to get it working :(
I'm not primitive, My time machine just malfunctioned in your era.
@cholasimmons, apologies for not being able to take a look at your problem for so long.

I had a look at the files you sent me and the problem, it seems, is this -
The original solution is based on the form's 'k_suuccess' code fabricating the search string which is then used by the cms:pages loop to filter pages fetched.

On your website, you've placed the form code after the cms:pages loop so basically when the cms:pages executes the search string is not yet created (which is done by the form further down the page after the cms:pages loop has already executed).

So, the bottom-line is that the filtered search code requires the form to run before the pages list while your design mandates that the form be show after the list.
So how do we reconcile this situation?
By using the cms:capture tag.
You can find it being used in our tutorial http://www.couchcms.com/docs/tutorials/ ... -form.html ('Buffering output')

The idea is to place the form code before the cms:pages listing but not to display it there. This we do by buffering its output using the cms:capture tag. You can then show the buffered output at the bottom where you currently do.
Code: Select all
<!-- make the form execute before the cms:pages loop -->
<cms:capture into='my_form_output' >
    <cms:form ..

    </cms:form>
</cms:capture>

<cms:pages ..

</cms:pages>

<!-- show the form after the pages -->
<cms:show my_form_output />

Hope this helps.
Took some time to understand but I have it workin now.

In the properties list-view page the search snippet has to appear BEFORE the pages tag, but not to display there and then, hence using capture to only display the form after the pages tag, assuming that's how your web page design is.

Awesome stuff KK, the algorithm used to search the cloned pages is a bit too strict though, it won't find Lusaka if you type Lusak. I know this is to do with the DB's way of storing data (or somthing like that) but would be good if it could take a chill pill on the seriousness..

But still, Thanks a whole lot!!
I'm not primitive, My time machine just malfunctioned in your era.
Glad you managed to get it to work, Simmons :)
the algorithm used to search the cloned pages is a bit too strict though, it won't find Lusaka if you type Lusak.

The search values are being inputted via dropdowns so we can be strict in our search.
If, however, a textfield is being used to input values, make a little change to the way the search string gets formulated -
Change the '==' to '='
e.g. make the following
<cms:set my_search_str="<cms:concat my_search_str ' | city=='frm_city />" scope='global'/>

into this
<cms:set my_search_str="<cms:concat my_search_str ' | city='frm_city />" scope='global'/>

With this change, users should be able to find Lusaka even if you they type Lusak.

Hope this helps.
This will have to do, in the textarea it won't find what ur lookin for unless u type the letters consecutively the way they follow each other in the actual word ur searching for. i.e: typing LSKA won't find Lusaka but typing SAKA will, or LUS, or USA... :P
I'm not primitive, My time machine just malfunctioned in your era.
I have implemented this code successfully, however there is one small problem.
This is the code implemented in my clonable template.

Code: Select all
</body>
</html>

<cms:else />
   <cms:embed 'blog_list.html' />
   Searching for:<cms:show my_search_str /><br /><!-- for debugging -->

      <cms:pages masterpage='events/event.php' paginate='1' limit='10' custom_field="<cms:show my_search_str />" orderby='event_datetime' order='asc' start_on="<cms:date format='Y-m-d' />" show_future_entries='1' >
         <cms:if k_paginated_top >
            <cms:set my_records_found='1' scope='global'/>
            <cms:if k_paginator_required >
               Page <cms:show k_current_page /> of <cms:show k_total_pages /><br />
            </cms:if>
            <cms:show k_total_records /> Properties Found. (Displaying: <cms:show k_record_from />-<cms:show k_record_to />)
         </cms:if>


         <h2><cms:show k_page_title /></h2>

         <cms:paginator simple='1' position='1' />
      </cms:pages>

      <cms:if my_records_found!='1' >
         No properties Found
      </cms:if>

</cms:if>
<?php COUCH::invoke(); ?>


The sort code is working successfully but the issue is that the results are getting listed at the bottom of my blog_list page after all my content.
As u can see in the code i pasted that the else tag has been put after the <html> tag as mentioned in your documentation.
I would like to know how can i list this piece of code to make it give output in my blog_list at the place where the posts are normally listed.
The original logic was -
Code: Select all
<cms:if k_is_page >
     
   <!-- show single property detail here -->

<cms:else />
   
      <!-- List view (shows search result) -->

</cms:if>

make it give output in my blog_list at the place where the posts are normally listed.
Place the cms:pages code doing the listing at whatever place you want the output to appear (paste it into your embedded 'blog_list.html' if you want) - just make sure that the code that pieces together the search string comes before the cms:pages code.
Yes thanks this is working properly now.
But i have also implemented the tags search feature so my code looks like this.

Code: Select all
<cms:pages folder=k_folder_name limit='10' paginate='1' custom_field="<cms:show my_search_str />" custom_field=my_query orderby='event_datetime' order='asc' start_on="<cms:date format='Y-m-d' />" show_future_entries='1'>


Now this only returns me the dropdown sorted results and incase i want to search by tags it still returns the dropdown sorted results.
Any chance by which i can sort the results by both?
Previous 1, 2, 3, 4, 5, 6 Next
59 posts Page 2 of 6

Who is online

In total there are 4 users online :: 0 registered, 0 hidden and 4 guests
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 4 guests

cron