Page tree
Skip to end of metadata
Go to start of metadata

Please see these pages for setting up Solr and configuring the plugin.

Newscoop templates

Instead of list_search_results you have to use list_search_results_solr. Params:




Query string. Default value: $_GET 'q' .


Fields to query. For Articles it can be title, type, webcode, authors, topics, keywords, custom article type field name (use Template Field Name). You can use multiple separated by space e.g. qf="title full_text". You can also boost relevancy of any field with ^number operator e.g. fq="title^3.4". Default value: title.

For other Content Type these fields are available:

  • User fields: user, bio

  • Comment fields: user, subject, message


Number of rows to be returned. Use for pagination. Default value: 10.


Number of row to start with. Use for pagination. Default value: 0.


Optional filter query. Can be used for results filtering e.g. fq="type:news". Also checkout the function build_solr_fq.


Set sorting of results. Default value: score desc. When using Solr plugin, use orderBy instead.

The form.

{{ form_search_solr id="search" class="hidden-phone" }}
  {{ form_text name="q" value=$smarty.get.q }}
  {{ form_submit name="" value=" " }}
{{ /form_search_solr }}

Listing the results <= 4.2

{{ list_search_results_solr fq={{ build_solr_fq }} qf="title^5 deck^3 full_text" start=$smarty.get.start }}
  {{ if $gimme->current_list->at_beginning }}
  {{ /if }}
    <li class="news_item  {{ cycle values="odd,even" }}">
      {{ image rendition="thumb" }}
      <img src="{{ $image->src }}"  alt="{{ $image->caption }} (photo: {{ $image->photographer }})"  />

      <div class="content">
        <h2 class="title"><a href="{{url options="article"}}">{{$gimme->article->title}}</a></h2>
        <h5 class="author">{{list_article_authors}}
        <p>{{$gimme->article->deck|strip_tags|truncate:200:"...":false}} </p>
  {{ if $gimme->current_list->at_end }}
  {{ /if }}
{{ /list_search_results_solr }}

Listing the results >= 4.3


As of version v0.9 of Solr plugin, "section_number" parameter has been added to "build_solr_fq" smarty function, to list results based on section number.


Also see Resources/sample_templates/search_index.tpl

{{ $listStart = $smarty.get.start|default:0 }}
{{ $listRows = 3 }}

{{ $fq = {{ build_solr_fq dateformat="d.m.Y" published=$smarty.get.published type=$types from=$smarty.get.from to=$ }} }}

{{ list_search_results_solr qf="title user message" q=$smarty.get.q fq=$fq rows=$listRows start=$listStart }}

    {{ if $gimme->current_list->at_beginning }}
        <p>{{ $gimme->current_list->count }} result(s) found.</p>
        <ul class="search-results-list">
    {{ /if }}
    {{ if $gimme->solr_result->getType() == 'article' }}
        <h6><a href="">{{ $gimme->solr_result->getObject()->name }}</a></h6>
    {{ elseif $gimme->solr_result->getType() == 'user' }}
        <h6>{{ $gimme->solr_result->getObject()->name }}</h6>
    {{ elseif $gimme->solr_result->getType() == 'comment' }}
        <h6>{{ $gimme->solr_result->getObject()->content }}</h6>
    {{ /if }}

    {{ if $gimme->current_list->at_end }}
    {{ /if }} 

{{ /list_search_results_solr }}
  • No labels