Skip to content

Instantly share code, notes, and snippets.

@croxton
Created September 9, 2011 16:42
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save croxton/1206694 to your computer and use it in GitHub Desktop.
Save croxton/1206694 to your computer and use it in GitHub Desktop.
Stash with Channel module: handling no results
{!-- build result rows --}
{exp:stash:set parse_tags="yes"}
{stash:results_rows}
{exp:channel:entries
channel="my_channel"
limit="10"
paginate="bottom"
}
<tr>
<td>{title}</td>
</tr>
{stash:absolute_results}{absolute_results}{/stash:absolute_results}
{paginate}
{stash:pagination_summary}Page {current_page} of {total_pages}{/stash:pagination_summary}
{stash:pagination_links}{pagination_links}{/stash:pagination_links}
{/paginate}
{/exp:channel:entries}
{/stash:results_rows}
{/exp:stash:set}
<!-- Results -->
<div class="data">
{if "{exp:stash:get name='absolute_results'}" == "0"}
<div class="results-header alt">
<p class="results-summary">No results</p>
</div>
{if:else}
<div class="results-header">
{exp:stash:get name='pagination_links'}
</div>
<table summary="results listing">
<thead>
<tr>
<th>Title</th>
</tr>
</thead>
<tbody>
{exp:stash:get name="results_rows"}
</tbody>
</table>
<div class="results-footer">
{exp:stash:get name='pagination_summary'}
{exp:stash:get name='pagination_links' random}
</div>
{/if}
</div>
<!-- /Results -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment