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 5 of 6
Previous 1, 2, 3, 4, 5, 6 Next
@KK, It really helped!! Thank you!! Sorry for the obvious question, I should have known)) :D
Hi,
I have a question for file named 'search.htm (file in snippet folder)

I have routes views - each inserted file from the same snippet folder:
<cms:if k_matched_route='list_view'>
<cms:embed 'list_view_content.inc' />
<cms:else_if k_matched_route='custom_1' />
<cms:embed 'custom_1_content.inc' />
... ...
</cms:if>

Both files (list_view_content.inc & custom_1_content.inc ) contain filtering.
My question is:
Do I need a file named search.htm, or I can put the code from search.htm directly into the page list_view_content.inc & custom_1_content.inc?

Ask for assistance
Thanks
Hi @orbital,

Code within a snippet behaves *exactly* as it would if it was placed directly within templates.
So, both the methods should work. By using snippets you'd avoid duplication of code though.
Thanks for the reply KK ;)
I thought it must have an external file, because in the code (search.htm) has frm_ variables
I know that in such cases is mandatory code to be placed in another file
Can someone help me!

I am creating a website for with sofa. he is very good.

My client asked to create a filtered search.

the busa item search records within adminstrativo panel.

and research related to each item. example:

(Type) (trademark) (model).

exempo.

selection (type of) car. when you select (mark) display unique brand as the type. when you select (model). show only the models registered with the type.

I have a website of a competitor example.

http://www.caminhoesecarretas.com.br/Default.aspx

somebody help me ?

It is possible with the couch?

I'm from Brazil I have difficulty :cry:
Hi guys!
I'm facing the following situation. I have:
1. documents.php which is a clonable template;
2. document-reports.php which is a template with no editables defined, used only for filtering the documents via
3. document-report-filter.html snippet.
The filtering is made by year, document type, author, etc. In this filter I would like to use year from the publish date, as publish date is already available, but I don't know how.
It is possible to use it somehow directly in the search string
Code: Select all
<cms:if frm_years!='-' >
            <cms:set my_search_str="<cms:concat my_search_str ' | docyear==' frm_years />"  scope='global'/>
         </cms:if>
, or year most be saved in documents.php template docyear editable previously to use it in the search string?
Any help is appreciated.

Attila
I would say, start_on & stop_before parameters can help here. Basically, start_on='2016-01-01' stop_before='2017-01-01'. But sometimes the years of the cloned pages vary and not known beforehand. In this case, please study <cms:archives /> tag, since it can get you a list of available years.
Thanks Trendoman for your suggestion.
However, I really would like to use the year from publish date somehow in a simpler manner if is possible. I forgot to mention the fact that when adding new documents from the front-end, I'm using KK's solution listed here http://www.couchcms.com/forum/viewtopic.php?f=4&t=8836&p=25585&hilit=edit+date+from+databound#p25585 , so the publish date is available, as user must input it from the front-end.
Code: Select all
<cms:db_persist_form
                    _invalidate_cache='0'
                    _auto_title='1'
                    k_publish_date=frm_my_datetime
                    author=my_name
          memberid=my_memberid
                    idfolder=my_page_id
                />
So I just have to grab the year part of frm_my_datetime somehow, and save it in an editable created for this in my documents.php template.
Am I right?
@atisz, please post your code (both showing years in filter and custom listing) so I could get you some easy code for years.

The solution with saving user-inputted year to editable is somewhat cumbersome, requires extra efforts which are not always reliable. It would be a big load for the server to fetch all cloned pages and find unique year from each of the page. Such tasks are managed by database 1000x faster. We should use proper tools :)
@trendoman
This is what I've done so far:
1. document-reports.php
Code: Select all
<div><!-- Start search snippet -->
   <cms:embed 'document-report-filter.html' />
</div><!-- End search snippet -->

<div id="navigation-bar">
   ......
</div>

<div id="table"><!-- Start table -->
   <table>
       <tr>
         <th>Date</th>
         <th>Document name</th>
         <th>Document type</th>
            <th>Author</th>
       </tr>                           
      <cms:pages masterpage='members/documents.php' custom_field=my_search_str order='asc' paginate='1' limit='20'>
         <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:if>
         <cms:if excludreg >
               ... do something ....                        
         <cms:else />
                <tr>
               <td><cms:date k_page_date format='d.m.Y' /></td>
               <td><cms:show docname /></td>
               <td><cms:show doctype /></td>
                    <td><cms:show author /></td>
             </tr>
            </cms:if>                  
      </cms:pages>
   </table>   
</div><!-- End table -->

2. document-report-filter.html
Code: Select all
   <cms:form name="quicksearch" id="quicksearch" anchor='0'>
      <cms:if k_success >
         
         <cms:if frm_years!='-' >
            <cms:set my_search_str="<cms:concat my_search_str ' | docyear==' frm_years />"  scope='global'/>
         </cms:if>
         
         <cms:if frm_doctypes!='-' >
            <cms:set my_search_str="<cms:concat my_search_str ' | doctype==' frm_doctypes />"  scope='global'/>
         </cms:if>
           
            <cms:if frm_authors!='-' >
            <cms:set my_search_str="<cms:concat my_search_str ' | author==' frm_authors />"  scope='global'/>
         </cms:if>
         
      </cms:if>
      
      <div>
         <label>Year:</label><br />
         <cms:input type="dropdown"
               opt_values="All=- | <cms:pages masterpage='members/years.php' order='asc'><cms:show year /><cms:if k_paginated_bottom='0' >|</cms:if></cms:pages>"
               opt_selected='All'
               name="years" id="years" />
      </div>
      <div>
         <label>Document type:</label><br />
         <cms:input type="dropdown"
                  opt_values="All=- | Internal | Incoming | Outgoing"
               opt_selected='All'
               name="doctypes" id="doctypes" />
      </div>
        <div>
         <label>Author:</label><br />
         <cms:input type="dropdown"
               opt_values="All=- | <cms:pages masterpage='members/index.php' order='asc'><cms:show k_page_title /><cms:if k_paginated_bottom='0' >|</cms:if></cms:pages>"
               opt_selected='All'
               name="authors" id="authors" />
      </div>
         <br />
      <div class="buttonset">
         <cms:input type="submit" class="fbsubmitbtn" value="Generate report" name="submit"/>
      </div>
   </cms:form>

Currently the year filter is working using the docyear field from documents.php, which is populated automatically with the year on form submition (add-document.php), but unfortunately the use case is a little special, from this reason the field is populated sometimes with the wrong year. That's why I was thinking to use year from publish date, because this is what matters and it is always correct, even if user edits it :)
Thanks!

Attila
Previous 1, 2, 3, 4, 5, 6 Next
59 posts Page 5 of 6

Who is online

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

Users browsing this forum: No registered users and 3 guests