Snippet Search on index.html View

13 views
Skip to first unread message

Una Gauper

unread,
Jun 23, 2016, 6:07:04 PM6/23/16
to apostrophenow
Hello,

I created a custom publications snippet and I'm trying enable a search feature on the index.html view. But when I enter a search, nothing happens.
The search works fine in the "Manage Publications" view. What am I missing? Github Repository

My publications/views/index.html

{% block main %}
  <div class="container">
    <div class="row">
      <div class="col-lg-12">
        <h2>TAADAS Statewide Clearinghouse Free Literature</h2>
      </div>
    </div>
    <div class="row">
    {{ aposArea(page, 'beforeContent') }}
       <div class="col-lg-4">
        <div id="my-requests">
        </div>
      </div>
      <div class="col-lg-8">
        <div class="apos-snippets publications row">
          {{ snippetSearchFilter() }}
          {{ renderSnippets(items, page.url) }}
        </div>
      </div>
         <div class="row">
        <div class="col-lg-8 col-lg-offset-4">
          {{ renderPager(pager, page.url) }}
        </div>
    </div>
  </div>
 
</div><!--container-->

{% endblock %}

My publicationMacros: (Everything not shown is the same as snippetMacros.html.)

{%- macro renderSnippets(items, pageUrl) -%}
  {%- if items -%}
    {%- for item in items -%}
      {{ renderSnippet(item, pageUrl) }}
    {%- endfor -%}
  {%- else -%}
    <h4>There are no snippets yet.</h4>
  {%- endif -%}
{%- endmacro -%}

{%- macro renderSnippet(item, pageUrl, options) -%}
  <div class="col-lg-12">
  <div class="apos-edit-snippet-button">
      {%- if options.edit and item._edit -%}
        <a class="apos-control apos-ui apos-button apos-edit-snippet-button" data-edit-{{ item.type | css }} data-slug="{{ item.slug }}" href="#"><i class="icon-pencil"></i> Edit</a>
      {%- endif -%}
      {%- if not item.hideTitle -%}
        <h4>
          {{ item.title | e }}
        </h4>
      {%- endif -%}
      <p> {{ item.description  }}</p>
  </div>
  </div>
  <div class="col-lg-3">
      {{ aposArea(item, 'thumbnail')}}
    </div>
    <div class="col-lg-9">
      {{ aposArea(item, 'body') }}
    </div>

    <div class="col-lg-12">
    {%- if item.physical -%}
    <div class="order-block">
      <button class="order btn btn-default" pubtitle="{{ item.title }}" identifier="{{ item.identifier }}">Request this item</button>
    </div>
  </div>
    {%- endif -%}

    <hr></hr>
  
  
{%- endmacro -%}


Tom Boutell

unread,
Jun 24, 2016, 9:47:12 AM6/24/16
to apostr...@googlegroups.com
Those macros aren't what you want for the frontend.

On the frontend just arrange it so your search form adds a "q" parameter to the URL of the index page.

--
You received this message because you are subscribed to the Google Groups "apostrophenow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to apostropheno...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--


THOMAS BOUTELL, SUPPORT LEAD
P'UNK AVENUE | (215) 755-1330  |  punkave.com

Una Gauper

unread,
Jun 24, 2016, 4:15:06 PM6/24/16
to apostrophenow
Thank you, I got it working!
Reply all
Reply to author
Forward
0 new messages