English فارسی Suomi
Français Nederlands Translate

Campsite 3.4

Campsite: CreatingASearchTemplate

Somebody Should Set The Title For This Chapter!

Here is a sample template for Search:

Anywhere you want the search form to appear, leading to the search result page, include this:

 {{ search_form template="path/to/search.tpl" submit_button="Search" html_code="class='FORM_suche'" button_html_code=" value='Suche' class='SUBMIT_black'" }}
    {{ camp_edit object="search" attribute="keywords" html_code="id=\"keywords\"" }}
{{ /search_form }}

The "path/to/search.tpl" refers to the relative path of the below template. If it lives in the top folder of your templates, just use "search.tpl" if you have subfolders (e.g. searchfiles), use "searchfiles/search.tpl". Attention: no leading slash!

<h2>Search</h2>
</div>
{{ search_form template="path/to/search.tpl" submit_button="Search" html_code="class='FORM_suchseite'" button_html_code="class='SUBMIT_search'" }}
  <ul class="searchform">
    <li class="searchform">
    <label for="keywords">Search words:</label>
    {{ camp_edit object="search" attribute="keywords" html_code="id=\"keywords\"" }}
    </li>
    <li class="option">
    {{ camp_select object="search" attribute="mode" html_code="id=\"match_all\"" }}
    <label for="match_all">Nur Artikel mit allen W&ouml;rtern anzeigen</label>
    </li>
    <li class="option checkbox"><input type="radio" name="f_search_scope" value="content" id="content" checked>
    <label for="content">Entire article</label></li>
    <li class="option checkbox"><input type="radio" name="f_search_scope" value="title" id="title">
    <label for="title">Only in title</label></li>
    <li class="option"><input type="radio" name="f_search_scope" value="author" id="author">
    <label for="author">Author</li>
  </ul>
 {{ camp_select object="search" attribute="level" }}
  <p>Search in the
    <input type="radio" name="f_search_scope" value="content" id="content" checked>
    <label for="content"><strong>whole content</strong></label>,
    <input type="radio" name="f_search_scope" value="title" id="title">
    <label for="title"><strong>title</strong></label> or
    <input type="radio" name="f_search_scope" value="author" id="author">
    <label for="author"><strong>author</strong></label>
  </p>
  <p>Issue: {{ camp_select object="search" attribute="issue" }}</p>
  <p>Section: {{ camp_select object="search" attribute="section" }}</p>
  <p>Start date: {{ camp_edit object="search" attribute="start_date" }}</p>
  <p>End date: {{ camp_edit object="search" attribute="end_date" }}</p>
  <p>Topic:
    <select name="f_search_topic">
      {{ unset_topic }}
      {{ list_subtopics }}
        <option value="{{ $campsite->topic->identifier }}>">
          {{ $campsite->topic->name }}
        </option>
      {{ /list_subtopics }}
    </select>
  </p>
{{ /search_form }}
<div class="searchresults">
<h2>Search results</h2>
    {{ list_search_results length="24" order="byDate desc" }}
    {{ if $campsite->current_list->at_beginning }}
            <ul class="filmsList">
    {{ /if }}
                <li>
                    <h5><a href="{{ url options="article" }}">{{ $campsite->article->name }}</a></h5>
                    <div><a href="{{ url options="article" }}">{{ $campsite->article->untertitel }}</a></div>
                    <span>(Issue: {{ $campsite->issue->name }}&nbsp;|&nbsp;Section: {{ $campsite->section->name }}
                </li>
       {{ if $campsite->current_list->at_end }}
    </ul>
          <ul class="pagination">
                <li>{{ $campsite->current_list->count }} Artikel</li>
{{ set_current_issue }}
{{ set_default_section }}
{{ unset_article }}
        {{ if $campsite->current_list->has_previous_elements }}
          <li class="previous"><a href="{{ uri options="previous_items template path/to/search.tpl" }}">&laquo;</a></li>
        {{ /if }}
{{ set_current_issue }}
{{ set_default_section }}
{{ unset_article }}
        {{ if $campsite->current_list->has_next_elements }}
          <li class="next"><a href="{{ uri options="next_items template path/to/search.tpl" }}">&raquo;</a></li>
        {{ /if }}
          </ul>
        {{ /if }}
     {{ /list_search_results }}
{{ if $campsite->prev_list_empty }}
                {{ if $campsite->search_articles_action->defined }}
                  <div class="warning">No matches found.</div>
              {{ /if }}
    {{ /if }}
  


EDIT